Re: references/addrresses in imperative languages

2005-06-20 Thread pete
Xah Lee wrote:
> 
> in coding Python yesterday, 

It seems to be giving you anxiety.
Have you considered not coding on python?

-- 
pete
-- 
http://mail.python.org/mailman/listinfo/python-list


Making a calendar

2005-02-26 Thread Pete.....
Hi all.

I'm trying to make a calendar for my webpage, python and html is the only 
programming languages that I know, is it possible to make such a calendar 
with pythong code and some html.

The Idea is that when I click the link calendar on my webpage, then the user 
will be linked to the calendar.

The calendar should show one month at the time, and the user should be able 
to browse to the other month.

I will make a script that puts events and such into a db ( I know how to do 
this)

Then I need a script that puts the events from the db into the calendar, if 
every day in the calendar has a value id that part will not be hard.

What I need is a script that generates the calender, in such a way that each 
month will be have a value, and that the user then can click the days to see 
more info about the events.

I was thinking something like the iMPcal calender: 
http://www.heidgerken.org/impcal2/calendar.php

Is there any modules I can use, or does any of you hardcore programmers have 
some advice on how I should proceed with this little project of mine :)

Thanks


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a calendar

2005-02-27 Thread Pete.....
Thanks all.

I will look at your links tonight :D
Hopefully they will make me smile and jump around as a happy man...

Cheers


"Brian Sutherland" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sat, Feb 26, 2005 at 01:57:20PM +0100, Pete. wrote:
>> I'm trying to make a calendar for my webpage, python and html is the only
>> programming languages that I know, is it possible to make such a calendar
>> with pythong code and some html.
>>
>> The Idea is that when I click the link calendar on my webpage, then the 
>> user
>> will be linked to the calendar.
>>
>> The calendar should show one month at the time, and the user should be 
>> able
>> to browse to the other month.
>>
>> I will make a script that puts events and such into a db ( I know how to 
>> do
>> this)
>>
>> Then I need a script that puts the events from the db into the calendar, 
>> if
>> every day in the calendar has a value id that part will not be hard.
>
> All this and more (perhaps overkill):
>
> http://www.schooltool.org/schoolbell
>
> -- 
> Brian Sutherland
>
> It's 10 minutes, 5 if you walk fast. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Working on a log in script to my webpage

2005-03-08 Thread Pete.....
Hi all I am working on a log in script for my webpage.

I have the username and the password stored in a PostgreSQL database.

The first I do is I make a html form, where the user can type in his 
username and code, when this is done I want to run the 
script(testifcodeisokay) that verifies that the code and username are the 
right ones ( that means if they match the particular entered username and 
password) If they are then I want to load page1 if they are not I want to 
load the loginpage again.

Login page:

print '''
 Username: 
 Code: '''

print ''
print ''' '''

This works.
Here I store the entered text in the variables "username" and "code"
I then get the entered value by

testifcodeisokay script

connect = PgSQL.connect(user="user", password="password", host="host", 
database="databse")
cur = connect.cursor()

form = cgi.FieldStorage()
username = form["username"].value
code= form["code"].value

I then want to test if they match the ones in the database

insert_command = "SELECT username, code FROM codetable WHERE 
codetable.username = '%s' AND codetable.code = '%s' " %(username, code)
cur.execute(insert_command)

I should then have found where the entered username,code (on the login page) 
is the same as those in the database.

But now I am stuck.

Does any know how I can then do something like:

If the codes from the loginpage matches the users codes in the db
Then the user should be taken to page1
IF the codes arnt correct the login page should load again.

The program dosnt need to remember who the user is, after the user has been 
loggen in, it is only used to log the user in.

Thanks for your time..



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-08 Thread Pete.....

>   How am I going to stop user from navigating directly to page1?
>
> Answering this question will involve learning about HTTP session state and 
> writing web applications. I could write a book on that subject :-)
>
> regards
>  Steve
>

Thanks Steve

And yes I havnt thought about that, guess I have to figure something else 
out. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-08 Thread Pete.....
The 2 scripts I made is actually working the way they where meant to. So im 
kindda happy :)

The problem is, that I didnt think about the problem: as Steve wrote:
 "There are other matters of concern, however, the most pressing of which 
is: How am I going to stop user from navigating directly to page1?"
Maybee I can find some premade feature, that prevents users to go to page1 
without logging in. Any ideas as to where I can find some information about 
this.

Nice that you all take time to help a newbie, so thanks to the helpfull 
people :)



> hi...
>
> regarding the issue of creating a login (user/passwd) script... there are
> numerous example scripts/apps written that use php/mysql... i suggest that
> you take a look at a few and then incoporate the features that you want 
> into
> your script.
>
> from your questions, it seems like this approach will give you a
> better/faster solution to your problem.
>
> -regards
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf
> Of Steve Holden
> Sent: Tuesday, March 08, 2005 4:02 PM
> To: python-list@python.org
> Subject: Re: Working on a log in script to my webpage
>
>
> Pete. wrote:
>> Hi all I am working on a log in script for my webpage.
>>
>> I have the username and the password stored in a PostgreSQL database.
>>
>> The first I do is I make a html form, where the user can type in his
>> username and code, when this is done I want to run the
>> script(testifcodeisokay) that verifies that the code and username are the
>> right ones ( that means if they match the particular entered username and
>> password) If they are then I want to load page1 if they are not I want to
>> load the loginpage again.
>>
>> Login page:
>>
>> print '''
>>  Username: 
>>  Code: '''
>>
>> print ''''''
>> print ''' '''
>>
>> This works.
>> Here I store the entered text in the variables "username" and "code"
>> I then get the entered value by
>>
>> testifcodeisokay script
>>
>> connect = PgSQL.connect(user="user", password="password", host="host",
>> database="databse")
>> cur = connect.cursor()
>>
>> form = cgi.FieldStorage()
>> username = form["username"].value
>> code= form["code"].value
>>
>> I then want to test if they match the ones in the database
>>
>> insert_command = "SELECT username, code FROM codetable WHERE
>> codetable.username = '%s' AND codetable.code = '%s' " %(username, code)
>> cur.execute(insert_command)
>>
> This is an amazingly bad choice of variable name, since the command
> doesn't actually insert anything into the database!
>
>> I should then have found where the entered username,code (on the login
> page)
>> is the same as those in the database.
>>
>> But now I am stuck.
>>
>> Does any know how I can then do something like:
>>
>> If the codes from the loginpage matches the users codes in the db
>> Then the user should be taken to page1
>> IF the codes arnt correct the login page should load again.
>>
>> The program dosnt need to remember who the user is, after the user has
> been
>> loggen in, it is only used to log the user in.
>>
>> Thanks for your time..
>>
> The Python you want is almost certainly something like
>
>   if len(curs.fetchall()) == 1:
> # username/password was found in db
>
> although unless your database is guarantees to contain only one of each
> combination it might be better to test
>
>   if len(curs.fetchall()) != 0:
> # username/password was found in db
>>
>>
> There are other matters of concern, however, the most pressing of which 
> is:
>
>   How am I going to stop user from navigating directly to page1?
>
> Answering this question will involve learning about HTTP session state
> and writing web applications. I could write a book on that subject :-)
>
> regards
>  Steve
>
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-09 Thread Pete.....
Hi again.

This question might sound a bit strange, but here I go anyway.

I found a tutorial on how to make member areas with ASP. ( It looked very 
complicated the info I found about making and using cookies to store session 
ID's with python)

Can I use python code and SQL statements in ASP.

The example only shows how to log in to a member area if the password is 
written in the asp code ( I mean the program dosnt connect to a my 
postgresql database to see if the username/password are correct.

I was thinking if I can use some of the code from the tutorial and put my 
own python code in, I will have solved my problem.

I dont know that much about asp but I also found a tutorial on that, which 
in going to read..

Thanks for your time.
The members area tutorial can be found here.
http://www.theukwebdesigncompany.com/article.php?id=392

"bruce" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> pete...
>
> simply use google and search for "php scripts login user authentication
> mysql session etc..."
>
> these terms will give you lots of examples... you could also look at some 
> of
> the bulletin board/forum apps that are open source to se what they use. 
> or,
> you could also look through the code for some of the php content 
> management
> apps... of course, there are also the open source ecommerce solutions. all
> of these types of apps have functionality to deal with the user
> login/registration issues...
>
> -regards,,,
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf
> Of Pete.
> Sent: Tuesday, March 08, 2005 6:26 PM
> To: python-list@python.org
> Subject: Re: Working on a log in script to my webpage
>
>
> The 2 scripts I made is actually working the way they where meant to. So 
> im
> kindda happy :)
>
> The problem is, that I didnt think about the problem: as Steve wrote:
> "There are other matters of concern, however, the most pressing of which
> is: How am I going to stop user from navigating directly to page1?"
> Maybee I can find some premade feature, that prevents users to go to page1
> without logging in. Any ideas as to where I can find some information 
> about
> this.
>
> Nice that you all take time to help a newbie, so thanks to the helpfull
> people :)
>
>
>
>> hi...
>>
>> regarding the issue of creating a login (user/passwd) script... there are
>> numerous example scripts/apps written that use php/mysql... i suggest 
>> that
>> you take a look at a few and then incoporate the features that you want
>> into
>> your script.
>>
>> from your questions, it seems like this approach will give you a
>> better/faster solution to your problem.
>>
>> -regards
>>
>>
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf
>> Of Steve Holden
>> Sent: Tuesday, March 08, 2005 4:02 PM
>> To: python-list@python.org
>> Subject: Re: Working on a log in script to my webpage
>>
>>
>> Pete. wrote:
>>> Hi all I am working on a log in script for my webpage.
>>>
>>> I have the username and the password stored in a PostgreSQL database.
>>>
>>> The first I do is I make a html form, where the user can type in his
>>> username and code, when this is done I want to run the
>>> script(testifcodeisokay) that verifies that the code and username are 
>>> the
>>> right ones ( that means if they match the particular entered username 
>>> and
>>> password) If they are then I want to load page1 if they are not I want 
>>> to
>>> load the loginpage again.
>>>
>>> Login page:
>>>
>>> print '''
>>>  Username: 
>>>  Code: '''
>>>
>>> print ''''''
>>> print ''' '''
>>>
>>> This works.
>>> Here I store the entered text in the variables "username" and "code"
>>> I then get the entered value by
>>>
>>> testifcodeisokay script
>>>
>>> connect = PgSQL.connect(user="user", password="password", host="host",
>>> database="databse")
>>> cur = connect.cursor()
>>>
>>> form = cgi.FieldStorage()
>>> username = form["username"].value
>>> code= form["code"].value
>>>
>>> I then want to test if they match the ones in the database
>>>
>>> insert_command = "SELECT username, code 

Re: Working on a log in script to my webpage

2005-03-09 Thread Pete.....
I better mention, that I rather make it all in python and html (found out 
that python somehow works with asp)

I know that what I have to do is the following:

1) When the user logs in, I have to store a session ID in a cookie
2) When page1 is loaded(upon correctly entered username/password) the cookie 
has to be sent to page 1 and on page one there should be a tjeck to see if 
the cookies has the right values.
3) everytime a page is loaded, there has to be a tjeck, to see if the 
cookies has the right value, if not the page shouldt be loaded, and the user 
should be redirected back to login page.

It does sound very easy to make: Create a store-holder(cookies), create a 
session ID upon log in, tjeck if it is the right sessionID in the cookies 
everytime a page is loaded, if not redirect back to log in page.

But eventhough it sounds easy, I cant quite get the hold of if..

I tried googling, but didnt really find anything, that helpfull...

Any more advice...

Once again thanks for your time

Sincerly
Pete
"Pete." <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi again.
>
> This question might sound a bit strange, but here I go anyway.
>
> I found a tutorial on how to make member areas with ASP. ( It looked very 
> complicated the info I found about making and using cookies to store 
> session ID's with python)
>
> Can I use python code and SQL statements in ASP.
>
> The example only shows how to log in to a member area if the password is 
> written in the asp code ( I mean the program dosnt connect to a my 
> postgresql database to see if the username/password are correct.
>
> I was thinking if I can use some of the code from the tutorial and put my 
> own python code in, I will have solved my problem.
>
> I dont know that much about asp but I also found a tutorial on that, which 
> in going to read..
>
> Thanks for your time.
> The members area tutorial can be found here.
> http://www.theukwebdesigncompany.com/article.php?id=392
>
> "bruce" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> pete...
>>
>> simply use google and search for "php scripts login user authentication
>> mysql session etc..."
>>
>> these terms will give you lots of examples... you could also look at some 
>> of
>> the bulletin board/forum apps that are open source to se what they use. 
>> or,
>> you could also look through the code for some of the php content 
>> management
>> apps... of course, there are also the open source ecommerce solutions. 
>> all
>> of these types of apps have functionality to deal with the user
>> login/registration issues...
>>
>> -regards,,,
>>
>>
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf
>> Of Pete.
>> Sent: Tuesday, March 08, 2005 6:26 PM
>> To: python-list@python.org
>> Subject: Re: Working on a log in script to my webpage
>>
>>
>> The 2 scripts I made is actually working the way they where meant to. So 
>> im
>> kindda happy :)
>>
>> The problem is, that I didnt think about the problem: as Steve wrote:
>> "There are other matters of concern, however, the most pressing of which
>> is: How am I going to stop user from navigating directly to page1?"
>> Maybee I can find some premade feature, that prevents users to go to 
>> page1
>> without logging in. Any ideas as to where I can find some information 
>> about
>> this.
>>
>> Nice that you all take time to help a newbie, so thanks to the helpfull
>> people :)
>>
>>
>>
>>> hi...
>>>
>>> regarding the issue of creating a login (user/passwd) script... there 
>>> are
>>> numerous example scripts/apps written that use php/mysql... i suggest 
>>> that
>>> you take a look at a few and then incoporate the features that you want
>>> into
>>> your script.
>>>
>>> from your questions, it seems like this approach will give you a
>>> better/faster solution to your problem.
>>>
>>> -regards
>>>
>>>
>>> -Original Message-
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED] Behalf
>>> Of Steve Holden
>>> Sent: Tuesday, March 08, 2005 4:02 PM
>>> To: python-list@python.org
>>> Subject: Re: Working on a log in script to my webpage
>>>
>>>
>>> Pete. wrote:
>>>> Hi all I am working on a log in script for my webpage.
>>>>
>>>> I have the username and the password stored in a PostgreSQL da

Re: Working on a log in script to my webpage

2005-03-09 Thread Pete.....
Thanks.

But I would really like to do this from scratch, so that I can learn it, I 
dont think I need that much more, before it works.

I found an example with asp, where the save the session if the password is 
correct. It isnt that long a code, so was wondering if it isnt possible to 
make something like that in python. Cause when this code is applied to the 
loginform, CODE2 will only have to be applied to every following page and 
everything is good.

code is from: 
http://tutorialized.com/tutorial/Creating-a-Members-Area-in-ASP/2234
CODE1
Set objRS = objConn.Execute (strSQL)
  '// see if there are any records returned
  If objRS.EOF Then
  'no username found
  strError = "- Invalid username or password" & vbNewLine
  Else
  'check password
  If objRS("password")=Request.Form("password") Then
   'username/password valid
   'save session data
   Session("loggedin") = True
   Session("userid") = objRS("id")
   'redirect to members area
   Response.Redirect ("default.asp")
   Response.End
  Else
   'invalid password
   strError = "- Invalid username or password" & vbNewLine

CODE2<%
If Session("loggedin") <> True Then Response.Redirect "login.asp"
%>


Members Area


Members Area
Welcome to our members area!
 In my code I have allready tested if the username and password is 
correct, so I just need to do the cookie thing :D

Thanks all, hope all my questions dosnt make you tired, I just really wanna 
figure this out, and I am doing this as a little hobby of mine, so I dont 
have anyone else to ask, hope that is okay...



"Kent Johnson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Pete. wrote:
>> Hi all I am working on a log in script for my webpage.
>>
>> I have the username and the password stored in a PostgreSQL database.
>
> You might want to look at Snakelets and CherryPy.
>
> Snakelets is "a very simple-to-use Python web application server." One of 
> the features is "Easy user authentication and user login handling."
> http://snakelets.sourceforge.net/
>
> CherryPy is "a pythonic, object-oriented web development framework" that 
> seems to be popular. A recipe for password-protected pages in CherryPy is 
> here:
> http://www.cherrypy.org/wiki/PasswordProtectedPages
>
> Kent 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working on a log in script to my webpage

2005-03-11 Thread Pete.....
Hi all.

Unfortunaly it looks like I dont have to skill to make a secure log in, cant 
figure out how the code has to look like, so guess my webpage has to live 
with a security issue.

Thanks for the effort you put into teaching me the use of cookies.

Best wishes
Pete

"Pete." <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Thanks.
>
> But I would really like to do this from scratch, so that I can learn it, I 
> dont think I need that much more, before it works.
>
> I found an example with asp, where the save the session if the password is 
> correct. It isnt that long a code, so was wondering if it isnt possible to 
> make something like that in python. Cause when this code is applied to the 
> loginform, CODE2 will only have to be applied to every following page and 
> everything is good.
>
> code is from: 
> http://tutorialized.com/tutorial/Creating-a-Members-Area-in-ASP/2234
> CODE1
> Set objRS = objConn.Execute (strSQL)
>  '// see if there are any records returned
>  If objRS.EOF Then
>  'no username found
>  strError = "- Invalid username or password" & vbNewLine
>  Else
>  'check password
>  If objRS("password")=Request.Form("password") Then
>   'username/password valid
>   'save session data
>   Session("loggedin") = True
>   Session("userid") = objRS("id")
>   'redirect to members area
>   Response.Redirect ("default.asp")
>   Response.End
>  Else
>   'invalid password
>   strError = "- Invalid username or password" & vbNewLine
>
> CODE2<%
> If Session("loggedin") <> True Then Response.Redirect "login.asp"
> %>
> 
> 
> Members Area
> 
> 
> Members Area
> Welcome to our members area!
>  In my code I have allready tested if the username and password is 
> correct, so I just need to do the cookie thing :D
>
> Thanks all, hope all my questions dosnt make you tired, I just really 
> wanna figure this out, and I am doing this as a little hobby of mine, so I 
> dont have anyone else to ask, hope that is okay...
>
>
>
> "Kent Johnson" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Pete. wrote:
>>> Hi all I am working on a log in script for my webpage.
>>>
>>> I have the username and the password stored in a PostgreSQL database.
>>
>> You might want to look at Snakelets and CherryPy.
>>
>> Snakelets is "a very simple-to-use Python web application server." One of 
>> the features is "Easy user authentication and user login handling."
>> http://snakelets.sourceforge.net/
>>
>> CherryPy is "a pythonic, object-oriented web development framework" that 
>> seems to be popular. A recipe for password-protected pages in CherryPy is 
>> here:
>> http://www.cherrypy.org/wiki/PasswordProtectedPages
>>
>> Kent
>
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: try / except not worknig correctly

2005-03-12 Thread Pete
'@'.join([..join(['fred','dixon']),..join(['gmail','com'])]) wrote:
1) the tutor list is really slow. but thanks.
2) Thanks Brain, i was missing the string bit. the code i posted (opps)
was not exactly where i was having problems, it just looked like it.
also thanks for the 'in' test, that will come in handy.
i am using chain because i need to do something different for each
twest.
is there a better way to return a tuple for each choice ?
You could try this:
>>> def doA():
print 'doing A'

>>> def doB():
print 'doing B'

>>> processFuncs = dict()
>>> processFuncs['A']  = doA
>>> processFuncs['B'] = doB
>>> while 1:
print 'Enter option:'
try:
myInput = raw_input('A or B?')
myInput = myInput.upper()
func = processFuncs[myInput]
func()
except KeyError, e:
print 'Opps wrong option', e
pass

Enter option:
A or B?A
doing A
Enter option:
A or B?B
doing B
Enter option:
A or B?C
Opps wrong option 'C'
Enter option:
A or B?
--
http://mail.python.org/mailman/listinfo/python-list


HTTP GET Explodes...

2006-09-23 Thread Pete
I was running the HTTP GET example at
http://www.python.org/doc/current/lib/httplib-examples.html and ran
into a bit of trouble...

>>> import httplib  # This works.
>>> conn = httplib.HTTPConnection("www.python.org")  # This works.
>>> conn.request("GET", "/index.html")  # This does not work...

The errors I get are below. Any suggestions on how to get rid of the
errors? Thanks!

# Begin errors...
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/httplib.py", line 801, in request
self._send_request(method, url, body, headers)
  File "/usr/lib/python2.4/httplib.py", line 818, in _send_request
self.putrequest(method, url, **skips)
  File "/usr/lib/python2.4/httplib.py", line 749, in putrequest
self.putheader('Host', self.host.encode("idna"))
  File "/usr/lib/python2.4/encodings/__init__.py", line 96, in
search_function
globals(), locals(), _import_tail)
  File "/usr/lib/python2.4/encodings/idna.py", line 6, in ?
dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
  File "/usr/lib/python2.4/sre.py", line 180, in compile
return _compile(pattern, flags)
  File "/usr/lib/python2.4/sre.py", line 225, in _compile
p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 500, in compile
code = _code(p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 481, in _code
_compile_info(code, p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 459, in _compile_info
_compile_charset(charset, flags, code)
  File "/usr/lib/python2.4/sre_compile.py", line 178, in
_compile_charset
for op, av in _optimize_charset(charset, fixup):
  File "/usr/lib/python2.4/sre_compile.py", line 221, in
_optimize_charset
return _optimize_unicode(charset, fixup)
  File "/usr/lib/python2.4/sre_compile.py", line 341, in
_optimize_unicode
mapping = array.array('b', mapping).tostring()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-23 Thread Pete
Fade in to episode II...

> ...
> This is compiling a *constant* regular expression, and works OK on the
> Windows distribution of Python 2.4.3 :

H. Here's the version information stuff:

Python 2.4.2 (#1, Feb 12 2006, 03:59:46)
[GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] on linux2

I'm going to upgrade Python and see if that has any effect...
I'm running this on a Fedora Core 5 box...

> ...
> You appear to be running 2.4.n; what is n, and exactly which *x
> platform are you running it on? Perhaps a file in /usr/lib/python2.4 is
> corrupt, but we won't know until you give the *full* traceback. Do you
> get the same results when you try what I did at the interpreter
> interactive prompt?

The error I received was from the interactive prompt thing. Is there
some way I can get more verbose information or something that would be
more helpful?

Thanks,
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-23 Thread Pete
> ...
> I'm going to upgrade Python and see if that has any effect...
> ...

I upgraded Python, it had an effect, but not a positive one. My
interactivity is below. Where is the "Hello World." text coming from?

Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib
>>> conn = httplib.HTTPConnection("www.python.org")
>>> conn.request("GET", "/index.html")
Hello World.
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/httplib.py", line 804, in request
self._send_request(method, url, body, headers)
  File "/usr/lib/python2.4/httplib.py", line 821, in _send_request
self.putrequest(method, url, **skips)
  File "/usr/lib/python2.4/httplib.py", line 752, in putrequest
self.putheader('Host', self.host.encode("idna"))
  File "/usr/lib/python2.4/encodings/__init__.py", line 96, in
search_function
globals(), locals(), _import_tail)
  File "/usr/lib/python2.4/encodings/idna.py", line 6, in ?
dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
  File "/usr/lib/python2.4/sre.py", line 180, in compile
return _compile(pattern, flags)
  File "/usr/lib/python2.4/sre.py", line 225, in _compile
p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 500, in compile
code = _code(p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 481, in _code
_compile_info(code, p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 459, in _compile_info
_compile_charset(charset, flags, code)
  File "/usr/lib/python2.4/sre_compile.py", line 178, in
_compile_charset
for op, av in _optimize_charset(charset, fixup):
  File "/usr/lib/python2.4/sre_compile.py", line 221, in
_optimize_charset
return _optimize_unicode(charset, fixup)
  File "/usr/lib/python2.4/sre_compile.py", line 341, in
_optimize_unicode
mapping = array.array('b', mapping).tostring()
TypeError: typecode argument must be a valid type.
>>>

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-23 Thread Pete
John Machin wrote:
> Pete wrote:
> > Fade in to episode II...
> >
> > > ...
> > > This is compiling a *constant* regular expression, and works OK on the
> > > Windows distribution of Python 2.4.3 :
> >
> > H. Here's the version information stuff:
> >
> > Python 2.4.2 (#1, Feb 12 2006, 03:59:46)
> > [GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] on linux2
> >
> > I'm going to upgrade Python and see if that has any effect...
> > I'm running this on a Fedora Core 5 box...
> >
> > > ...
> > > You appear to be running 2.4.n; what is n, and exactly which *x
> > > platform are you running it on? Perhaps a file in /usr/lib/python2.4 is
> > > corrupt, but we won't know until you give the *full* traceback. Do you
> > > get the same results when you try what I did at the interpreter
> > > interactive prompt?
> >
> > The error I received was from the interactive prompt thing.
>
> So I noticed from your first posting. Now do what you were asked: try
> what I did.
>
> > Is there
> > some way I can get more verbose information or something that would be
> > more helpful?
> >
>
> Yes, just include the whole traceback!!! Example of what I mean is
> below:

Here's my full interactive I/O:

Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib
>>> conn = httplib.HTTPConnection("www.python.org")
>>> conn.request("GET", "/index.html")
Hello World.
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/httplib.py", line 804, in request
self._send_request(method, url, body, headers)
  File "/usr/lib/python2.4/httplib.py", line 821, in _send_request
self.putrequest(method, url, **skips)
  File "/usr/lib/python2.4/httplib.py", line 752, in putrequest
self.putheader('Host', self.host.encode("idna"))
  File "/usr/lib/python2.4/encodings/__init__.py", line 96, in
search_function
globals(), locals(), _import_tail)
  File "/usr/lib/python2.4/encodings/idna.py", line 6, in ?
dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
  File "/usr/lib/python2.4/sre.py", line 180, in compile
return _compile(pattern, flags)
  File "/usr/lib/python2.4/sre.py", line 225, in _compile
p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 500, in compile
code = _code(p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 481, in _code
_compile_info(code, p, flags)
  File "/usr/lib/python2.4/sre_compile.py", line 459, in _compile_info
_compile_charset(charset, flags, code)
  File "/usr/lib/python2.4/sre_compile.py", line 178, in
_compile_charset
for op, av in _optimize_charset(charset, fixup):
  File "/usr/lib/python2.4/sre_compile.py", line 221, in
_optimize_charset
return _optimize_unicode(charset, fixup)
  File "/usr/lib/python2.4/sre_compile.py", line 341, in
_optimize_unicode
mapping = array.array('b', mapping).tostring()
TypeError: typecode argument must be a valid type.
>>>

>
> | C:\junk>copy con wally.py
> | guff = 1 / 0
> | ^Z
> | 1 file(s) copied.
> |
> | C:\junk>python
> | Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
> on win32
> | Type "help", "copyright", "credits" or "license" for more
> information.
> | >>> import wally
> | Traceback (most recent call last):
> |   File "", line 1, in ?
>
> Your posting appeared truncated when viewed with both Google groups and
> in a regular newsreader.

I clipped out stuff that didn't seem relevant. I didn't clip anything
out this time.

> There is no guarantee that the last line shown is the one that caused
> the error.
> Just as if this example were missing the following lines, we don't know
> which
> source line caused the error, nor even what the error was!!
>
> |   File "wally.py", line 1, in ?
> | guff = 1 / 0
> | ZeroDivisionError: integer division or modulo by zero
>
> HTH,
> John

I'm still lost... Were you able to successfully run the GET example at
http://www.python.org/doc/current/lib/httplib-examples.html ?

Thanks for your help!
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


What is the best way to "get" a web page?

2006-09-23 Thread Pete
I have the following code:

>>> web_page = urllib.urlopen("http://www.python.org";)
>>> file = open("temp.html", "w")
>>> web_page_contents = web_page.read()
>>> file.write(web_page_contents)
>>> file.close

>>>

The file "temp.html" is created, but it doesn't look like the page at
www.python.org. I'm guessing there are multiple frames and my code did
not get everything. Can anyone point me to a tutorial or other
reference on how to "get" all of the html contents at a particular
page?

Why did Python print the line after "file.close"?

Thanks,
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best way to "get" a web page?

2006-09-23 Thread Pete
> >I have the following code:
> >
> >>>> web_page = urllib.urlopen("http://www.python.org";)
> >>>> file = open("temp.html", "w")
> >>>> web_page_contents = web_page.read()
> >>>> file.write(web_page_contents)
> >>>> file.close
> > 
> >>>>
> >
> > The file "temp.html" is created, but it doesn't look like the page at
> > www.python.org. I'm guessing there are multiple frames and my code did
> > not get everything. Can anyone point me to a tutorial or other
> > reference on how to "get" all of the html contents at a particular
> > page?
> >
> > Why did Python print the line after "file.close"?
> >
> > Thanks,
> > Pete
> >
>
> A. You didn't actually invoke the close method, you simply referenced it,
> which is why you got the output line after file.close.  Python is not VB.
> To call close, you have to follow it with ()'s, as in:
>
> file.close()

A. Thank you very much!

> This will have the added benefit of flushing the output to temp.html,
> probably containing the missing content you were looking for.
>
> B. Don't name variables "file", or "list", "str", "dict", "int", etc.  Doing
> so masks global names of builtin data types.  Try "tempFile" instead.

Oh. Thanks again!
The file "temp.html" is definitely different than the first run, but
still not anything close to www.python.org . Any other suggestions?

Thanks,
Pete

> -- Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-23 Thread Pete
> > Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
> > [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import httplib
> > >>> conn = httplib.HTTPConnection("www.python.org")
> > >>> conn.request("GET", "/index.html")
> > Hello World.
>
>   Off-hand -- I'd suggest you do a search of your computer for any
> occurrence of
>   httplib.py
>   httplib.pyc
>   httplib.pyo
> on the odd chance that you are picking up some corrupted version...

Problem solved (sort of...). I searched for "httplib*". I had some
cygwin stuff archived on my Linux box, but the cygwin stuff wasn't in
my search path, but on an odd chance I renamed the cygwin httplib*
files to something else. Problem persisted. On another odd chance I
fired up "python" as root, plugged in the example at
http://www.python.org/doc/current/lib/httplib-examples.html, and things
were clicking... There was a problem with "r2", but that was
understandable...

In my confused state I created a new user, fired up python, slung the
example code, and had no problem (except for "r2", but that was
understandable).

So, I looked at my search path under the account that was experiencing
the problem. That wasn't it... Then I'm thinking there's an
environmental variable causing this. Too many to work right now. Will
investigate later.

So, the problem lies somewhere in the account running Python... Not
sure how/why...

Thanks to all!,
Pete

>
> -=-=-=-=-=-=-=-
> PythonWin 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)]
> on win32.
> Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
> see 'Help/About PythonWin' for further copyright information.
> >>> import httplib
> >>> conn = httplib.HTTPConnection("www.python.org")
> >>> conn.request("GET", "/index.html")
> >>> resp = conn.getresponse()
> >>> print resp.getheaders()
> [('content-length', '12196'), ('accept-ranges', 'bytes'), ('server',
> 'Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.1.4 mod_python/3.1.3
> Python/2.3.5 mod_ssl/2.0.54 OpenSSL/0.9.7e'), ('last-modified', 'Sat, 23
> Sep 2006 23:49:01 GMT'), ('etag', '"61b82-2fa4-99e01540"'), ('date',
> 'Sun, 24 Sep 2006 03:26:30 GMT'), ('content-type', 'text/html')]
> >>> print resp.read()
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-23 Thread Pete
> > Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
> > [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import httplib
> > >>> conn = httplib.HTTPConnection("www.python.org")
> > >>> conn.request("GET", "/index.html")
> > Hello World.
>
>   Off-hand -- I'd suggest you do a search of your computer for any
> occurrence of
>   httplib.py
>   httplib.pyc
>   httplib.pyo
> on the odd chance that you are picking up some corrupted version...

Problem solved (sort of...). I searched for "httplib*". I had some
cygwin stuff archived on my Linux box, but the cygwin stuff wasn't in
my search path, but on an odd chance I renamed the cygwin httplib*
files to something else. Problem persisted. On another odd chance I
fired up "python" as root, plugged in the example at
http://www.python.org/doc/current/lib/httplib-examples.html, and things
were clicking... There was a problem with "r2", but that was
understandable...

In my confused state I created a new user, fired up python, slung the
example code, and had no problem (except for "r2", but that was
understandable).

So, I looked at my search path under the account that was experiencing
the problem. That wasn't it... Then I'm thinking there's an
environmental variable causing this. Too many to work right now. Will
investigate later.

So, the problem lies somewhere in the account running Python... Not
sure how/why...

Thanks to all!,
Pete

>
> -=-=-=-=-=-=-=-
> PythonWin 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)]
> on win32.
> Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
> see 'Help/About PythonWin' for further copyright information.
> >>> import httplib
> >>> conn = httplib.HTTPConnection("www.python.org")
> >>> conn.request("GET", "/index.html")
> >>> resp = conn.getresponse()
> >>> print resp.getheaders()
> [('content-length', '12196'), ('accept-ranges', 'bytes'), ('server',
> 'Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.1.4 mod_python/3.1.3
> Python/2.3.5 mod_ssl/2.0.54 OpenSSL/0.9.7e'), ('last-modified', 'Sat, 23
> Sep 2006 23:49:01 GMT'), ('etag', '"61b82-2fa4-99e01540"'), ('date',
> 'Sun, 24 Sep 2006 03:26:30 GMT'), ('content-type', 'text/html')]
> >>> print resp.read()
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP GET Explodes...

2006-09-24 Thread Pete
> > > > Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
> > > > [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
> > > > Type "help", "copyright", "credits" or "license" for more information.
> > > > >>> import httplib
> > > > >>> conn = httplib.HTTPConnection("www.python.org")
> > > > >>> conn.request("GET", "/index.html")
> > > > Hello World.
> > >
> > >   Off-hand -- I'd suggest you do a search of your computer for any
> > > occurrence of
> > >   httplib.py
> > >   httplib.pyc
> > >   httplib.pyo
> > > on the odd chance that you are picking up some corrupted version...
> >
>
> Don't search; just open the lid and read the label that's tied around
> the culprit's neck; example:
>
> | >>> import httplib
> | >>> httplib.__file__
> | 'c:\\python24\\lib\\httplib.pyc'
>
> If you want to see where it finds *everything* that's imported, run
> Python with the -v arg.
> If you want to see where it looks for each module imported, use -vv
> (that's vee vee, not dubya).
>
> HTH,
> John
>
> HTH,
> John

Thanks to all for your assistance. Not sure what the problem was, but
the problem no longer exists. In an attempt to track down the
environmental variables I rebooted the system a few times and the
example code I was working with does indeed work on my system.

After upgrading python I exited my interactive session and jumped back
in to an interactive session which displayed the new python version
number. Experienced problems. Now, no problems. Not sure what made the
problem(s) go away... Very odd...
--
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best way to "get" a web page?

2006-09-24 Thread Pete
> > The file "temp.html" is definitely different than the first run, but
> > still not anything close to www.python.org . Any other suggestions?
>
> If you mean that the page looks different in a browser, for one thing
> you have to download the css files too. Here's the relevant extract
> from the main page:
>
>  type="text/css" id="screen-switcher-stylesheet" rel="stylesheet" />
>  rel="stylesheet" />
>  rel="stylesheet" />
>  rel="alternate stylesheet" title="large text" />
>  rel="alternate stylesheet" title="default fonts" />
>
> You may either hardcode the urls of the css files, or parse the page,
> extract the css links and normalize them to absolute urls. The first is
> simpler but the second is more robust, in case a new css is added or an
> existing one is renamed or removed.
>
> George

Thanks for the information on CSS. I'll look into that later, but now
my question is on the first two lines of HTML code. Here's my latest
python code:

>>> import urllib
>>> web_page = urllib.urlopen("http://www.python.org";)
>>> fileTemp = open("temp.html", "w")
>>> web_page_contents = web_page.read()
>>> fileTemp.write(web_page_contents)
>>> fileTemp.close()

Here are the first two lines of temp.html:

  1 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 http://www.w3.org/1999/xhtml";>

Here are the first two lines of www.python.org as saved from Firefox:

  1 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 http://www.w3.org/1999/xhtml";
lang="en">

Lines one are identical. Lines two are different. Why would lines two
differ? H...

Thanks,
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best way to "get" a web page?

2006-09-24 Thread Pete
> > Can anyone point me to a tutorial or other reference on how to "get" all
> > of the html contents at a particular page?
>
> Why not use httrack?
>
> http://www.satzbau-gmbh.de/staff/abel/httrack-py/
>
> Sincerely,
>
> Wolfgang Keller
>
> --
> My email-address is correct.
> Do NOT remove ".nospam" to reply.

Thanks for the tip. I'll check that out. Is that your code?
--
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best way to "get" a web page?

2006-09-24 Thread Pete
> > Functionally they are the same, but third line included in Firefox.
> > Opera View Source command produces the same result as Python.
> [snip]
>
> It's better to compare with the result of a downloader-only (instead
> of a parser), like wget on Unix. That way you'll get exactly the same
> bytes (assuming the page is static).
>
> --
> Felipe.

A. wget - most cool. My temp.html matches wget. Now to capture that
pesky css stuff...

Thanks,
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Concurrency Email List

2009-05-18 Thread Pete

On May 16, 2009, at 7:26 PM, Aahz wrote:


[posted and e-mailed]

On Sat, May 16, 2009, Pete wrote:


python-concurre...@googlegroups.com is a new email list for  
discussion
of concurrency issues in python.  It arose out of Dave Beazley's  
class

on the subject last week: http://www.dabeaz.com/chicago/concurrent.html

The list wills serve as a forum for discussion of such topics as:

* threads
* multiprocessing
* asynchronous
* coroutines
* the GIL

Hope to see you there!  Join at 
http://groups.google.com/group/python-concurrency/


Is there some reason you chose not to create a list on python.org?   
I'm

not joining the list because Google requires that you create a login.


Because it took less time to create the group on Google than it took  
for me to even find the instructions for doing so on python.org (still  
looking).  That said, I'm happy to move if someone would like to point  
me in the right direction/facilitate.

--
http://mail.python.org/mailman/listinfo/python-list


Uninstalling Python

2006-03-29 Thread Pete
I am using xpsp2, and I have two versions of python (2.2 and 2.2.3 - both 
are listed as 29.3 mb, and listed as rarely used, which means never to me) 
listed in add/remove programs in the control panel.  I assume they were put 
in by HP out of the factory install, when I got my pc last April, since I 
certainly did not install the first one or do an update to it.

I googled "python" and have no interest in it and know nothing about it.

Therefore, I would like to uninstall  both the versions since I do not 
believe I need them.  Would it be okay to uninstall them or would you 
recommend that I keep them even though I will probably never use them (ie 
for the future just in case).  Or could something else get screwed up if I 
uninstalled them.  Is this analogous to java (which I also do not believe I 
have a need for).

Thanks...Pete 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Uninstalling Python

2006-03-29 Thread Pete
Ben Finney wrote:
> "Pete" <[EMAIL PROTECTED]> writes:
>
>> I googled "python" and have no interest in it and know nothing about
>> it.
>>
>> Therefore, I would like to uninstall  both the versions since I do
>> not believe I need them.  Would it be okay to uninstall them or
>> would you recommend that I keep them even though I will probably
>> never use them (ie for the future just in case).
>
> It should be okay to uninstall *any* software on your system if you
> believe you don't want it.
>
> If you don't have a system that defaults to removing software without
> checking if other packages depend on it, I'd hope you have stern words
> to say to your operating system vendor and seek out more user-friendly
> operating systems.

Thanks Ben...I told you in my very first few words who my operating system 
vendor was (ie non other than "Bill Gates").  I said I was using xpsp2.  So 
do all "windows" xp computer operating systems do what you said (ie, check 
if other packages depend on something that you are uninstalling).  I would 
certainly hope so, since MS is the world leader with "windows".  I am not a 
pc guru like you are, so when you tell me to seek out more user friendly 
operator systems, it is over my head.  I buy my pc's out of the box with 
windows installed on them...Pete


>
> On the other hand, if packaged programs depend on other packages but
> don't use the operating system package manager to declare this, those
> programs are poorly packaged.
>
> In short: it's your computer. We hope you'll one day be interested
> enough in Python to want to use it some more. For now, if you want to
> uninstall it, you should feel free, and demand an explanation from
> anything that breaks as a result. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Uninstalling Python

2006-03-29 Thread Pete
John Salerno wrote:
> Robert Kern wrote:
>
>> "Why is Python Installed on my Computer?" FAQ:
>> http://www.python.org/doc/faq/installed/
>
> Most importantly from that link:
>
> Some Windows machines also have Python installed. At this writing
> we're aware of computers from Hewlett-Packard and Compaq that include
> Python. Apparently some of HP/Compaq's administrative tools are
> written in Python.

Thanks to Everyone...I will leave it to be safe.  I  don't think I will ever 
need any of HP's tools or utilities either, but I will leave it.  Am I 
correct in assuming that "administrative tools" and "user accounts" in the 
control panel is windows driven and not HP driven (excuse my choice of words 
if not correct).  This gets into the folders in c:\docs and settings, so I'm 
not sure what the interface is between the windows operating system and 
HP...Pete 


-- 
http://mail.python.org/mailman/listinfo/python-list


Ignoring XML Namespaces with ElementTree

2009-12-03 Thread Pete
Is there anyway to configure ElementTree to ignore the XML namespace?
For the past couple months, I've been using minidom to parse an XML
file that is generated by a unit within my organization that can't
stick with a standard. This hasnt been a problem until recently when
the script was provided a 30MB file that once parsed, increased the
python memory footprint by 1.0GB and now I'm running into Memory
Errors. Based on Google searches and testing it looks like ElementTree
is much more efficient with memory and I'd like to switch, however I'd
like to be able to ignore the namespaces. These XML files tend to
randomly switch the namespace for no reason and ignoring these
namespaces would help the script adapt to the changes. Any help on
this would be greatly appreciated. I'm having a hard time finding the
answer.

Additionally, anyone know how ElementTree handle's XML elements that
include Unicode?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ignoring XML Namespaces with ElementTree

2009-12-03 Thread Pete
On Dec 3, 2:55 pm, Stefan Behnel  wrote:
> Pete, 03.12.2009 19:21:
>
> > Is there anyway to configure ElementTree to ignore the XML namespace?
> > For the past couple months, I've been using minidom to parse an XML
> > file that is generated by a unit within my organization that can't
> > stick with a standard. This hasnt been a problem until recently when
> > the script was provided a 30MB file that once parsed, increased the
> > python memory footprint by 1.0GB and now I'm running into Memory
> > Errors. Based on Google searches and testing it looks like ElementTree
> > is much more efficient with memory and I'd like to switch,
>
> Make sure you use cElementTree, then that's certainly the right choice to 
> make.
>
> > however I'd
> > like to be able to ignore the namespaces. These XML files tend to
> > randomly switch the namespace for no reason and ignoring these
> > namespaces would help the script adapt to the changes. Any help on
> > this would be greatly appreciated. I'm having a hard time finding the
> > answer.
>
> ET uses namespace URIs as part of the tag name, so if you want to ignore
> namespaces, just strip the leading "{...}" (if any) from the tag and work
> with the rest (so-called "local name").
>
> > Additionally, anyone know how ElementTree handle's XML elements that
> > include Unicode?
>
> It's an XML parser, so the answer is: without any difficulties.
>
> Stefan

Perfect... I can work with that. Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Popen and reading stdout in windows

2013-06-11 Thread Pete Forman
"Joseph L. Casale"  writes:

>> You leave out an awful amount of detail. I have no idea what ST is,
>> so I'll have to guess your real problem.
>
> Ugh, sorry guys its been one of those days, the post was rather
> useless...
>
> I am using Popen to run the exe with communicate() and I have sent
> stdout to PIPE without luck. Just not sure what is the proper way to
> iterate over the stdout as it eventually makes its way from the
> buffer.

You could try Sarge which is a wrapper for subprocess providing command
pipeline functionality.

http://sarge.readthedocs.org/

-- 
Pete Forman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing ISO date/time strings - where did the parser go?

2012-09-12 Thread Pete Forman
John Nagle  writes:

>I want to parse standard ISO date/time strings such as
>
>   2012-09-09T18:00:00-07:00
>
> into Python "datetime" objects.

Consider whether RFC 3339 might be a more suitable format.

It is a subset of ISO 8601 extended format.  Some of the restrictions are

  Year must be 4 digits
  Fraction separator is period, not comma
  All components including time-offset are mandatory, except for time-secfrac
  time-minute in time-offset is not optional, must use ±hh:mm or Z

Some latitude is allowed

  T may be replaced by e.g. space

Extra feature

  time-offset of -00:00 means UTC but local time is unknown

-- 
Pete Forman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL or something to open EXIF Metadata with Python

2013-01-10 Thread Pete Forman
Tim Golden  writes:

> On 09/01/2013 14:45, Jose Trevino wrote:
>> I am trying to load the PIL module to manage exif metadata with
>> Python but have had no success. 
>
>
> Try pyexiv2:
>
>   http://tilloy.net/dev/pyexiv2/
>
> TJG

Or Hachoir

http://pypi.python.org/pypi/hachoir-metadata
https://bitbucket.org/haypo/hachoir/wiki/Home

-- 
Pete Forman
-- 
http://mail.python.org/mailman/listinfo/python-list


setdefault behaviour question

2012-05-19 Thread pete McEvoy
I am confused by some of the dictionary setdefault behaviour, I think
I am probably missing the obvious here.

def someOtherFunct():
print "in someOtherFunct"
return 42

def someFunct():
myDict = {1: 2}
if myDict.has_key(1):
print "myDict has key 1"
x = myDict.setdefault(1, someOtherFunct())   # < I didn't
expect someOtherFunct to get called here
print "x", x
y = myDict.setdefault(5, someOtherFunct())
print "y", y


+

if I call someFunct() I get the following output

myDict has key 1
in someOtherFunct
x 2
in someOtherFunct
y 42


For the second use of setdefault I do expect a call as the dictionary
does not the key. Will the function, someOtherFunct, in setdefault
always be called anyway and it is just that the dictionary will not be
updated in any way?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setdefault behaviour question

2012-05-19 Thread pete McEvoy
Ah - I have checked some previous posts (sorry, should
have done this first) and I now can see that the
lazy style evaluation approach would not be good.
I can see the reasons it behaves this way.

many thanks anyway.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-15 Thread Pete Forman
Andrew Z  writes:

> hmm. i did do that.  maybe just a delay.
> I'll see how it will go tomorrow then. Thank you gents.
>
> On Mon, Oct 16, 2017 at 12:30 AM, Chris Angelico  wrote:
>
>> On Mon, Oct 16, 2017 at 3:19 PM, Andrew Z  wrote:
>> > Michael, that's what i use too - gmail. But i get the digest only
>> > and can't really reply that way. i was hoping to get the
>> > mail.python.org list
>>
>> Turn off digests then. Easy!

If you do stick with a digest then check your newsreader for a feature
to expand it. Then you can read and reply as if you were getting
individual posts.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-16 Thread Pete Forman
Thomas Jollans  writes:

> On 2017-10-16 08:48, Pete Forman wrote:
>> Andrew Z  writes:
>>
>>> hmm. i did do that.  maybe just a delay.
>>> I'll see how it will go tomorrow then. Thank you gents.
>>>
>>> On Mon, Oct 16, 2017 at 12:30 AM, Chris Angelico  wrote:
>>>
>>>> On Mon, Oct 16, 2017 at 3:19 PM, Andrew Z  wrote:
>>>>> Michael, that's what i use too - gmail. But i get the digest only
>>>>> and can't really reply that way. i was hoping to get the
>>>>> mail.python.org list
>>>>
>>>> Turn off digests then. Easy!
>>
>> If you do stick with a digest then check your newsreader for a feature
>> to expand it. Then you can read and reply as if you were getting
>> individual posts.
>>
> That exists? How does it work?

The Gnus newsreader in Emacs allows you to type C-d on a digest to run
gnus-summary-enter-digest-group. That then behaves the same as if you
opened any other summary such as a regular Usenet group.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to read in the newsreader

2017-10-17 Thread Pete Forman
Thomas Jollans  writes:

> On 16/10/17 20:02, Pete Forman wrote:
>> Thomas Jollans  writes:
>> 
>>> On 2017-10-16 08:48, Pete Forman wrote:
>>>> Andrew Z  writes:
>>>>
>>>>> hmm. i did do that.  maybe just a delay.
>>>>> I'll see how it will go tomorrow then. Thank you gents.
>>>>>
>>>>> On Mon, Oct 16, 2017 at 12:30 AM, Chris Angelico  wrote:
>>>>>
>>>>>> On Mon, Oct 16, 2017 at 3:19 PM, Andrew Z  wrote:
>>>>>>> Michael, that's what i use too - gmail. But i get the digest only
>>>>>>> and can't really reply that way. i was hoping to get the
>>>>>>> mail.python.org list
>>>>>>
>>>>>> Turn off digests then. Easy!
>>>>
>>>> If you do stick with a digest then check your newsreader for a feature
>>>> to expand it. Then you can read and reply as if you were getting
>>>> individual posts.
>>>>
>>> That exists? How does it work?
>> 
>> The Gnus newsreader in Emacs allows you to type C-d on a digest to run
>> gnus-summary-enter-digest-group. That then behaves the same as if you
>> opened any other summary such as a regular Usenet group.
>> 
>
> Does it set the References header correctly when replying?

Sorry, I am not in a position to test. The only digest I subscribe to is
comp.risks. The only messsage id in that is a single one for the whole
digest. Each article only has date, subject and from headers. You would
need to look inside a Python digest to see if it carries more headers
for the articles. If they are not present then they cannot be used when
composing a reply.

-- 
Pete Forman
https://payg.pythonanywhere.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-01 Thread Pete Forman
mark...@gmail.com writes:

> On Thursday, February 1, 2018 at 6:01:58 PM UTC+1, superchromix wrote:
>> Our own programming discussion newsgroup, located at
>> comp.lang.idl-pvwave, started receiving spam messages several months
>> ago.
>>
>> Two weeks ago, access to comp.lang.idl-pvwave was blocked by Google
>> Groups.
>>
>> When trying to access comp.lang.idl-pvwave, a message is now
>> displayed, stating that the group owner needs to remove the spam,
>> and can then apply to Google in order to have access reinstated.
>>
>> However, old public Usenet groups like this have no owner. The
>> comp.lang.idl-pvwave group is more than 20 years old. Hence, there
>> is no way to unblock the group.
>>
>> This is a serious problem, since the entire collection of postings
>> going back many years has been blocked, no just the spam. This
>> resource is frequently used by IDL programmers.
>>
>> Seeing the spam postings in this newsgroup, I expect something
>> similar may happen to comp.lang.python, soon.
>
> The problem I have now is that there is no public, searchable archive
> of comp.lang.idl-pvwave available. This was the real benefit of Google
> groups, from my point of view.
>
> There is something called "narkive", but its search function seems to
> be broken, and it doesn't archive very far back in time.

A couple of other mail archivers are:

https://www.mail-archive.com
https://marc.info

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Pete Forman
"Michael F. Stemper"  writes:

> On 21/09/2021 13.49, alister wrote:
>> On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:
> It's my own research, so I can give myself the data in any format that I
> like.
>
>> as far as I can see the main issue with XML is bloat, it tries to do
>> too many things & is a very verbose format, often the quantity of
>> mark-up can easily exceed the data contained within it. other formats
>> such a JSON & csv have far less overhead, although again not always
>> suitable.
>
> I've heard of JSON, but never done anything with it.

Then you should certainly try to get a basic understanding of it. One
thing JSON shares with XML is that it is best left to machines to
produce and consume. Because both can be viewed in a text editor there
is a common misconception that they are easy to edit. Not so, commas are
a common bugbear in JSON and non-trivial edits in (XML unaware) text
editors are tricky.

Consider what overhead you should worry about. If you are concerned
about file sizes then XML, JSON and CSV should all compress to a similar
size.

> How does CSV handle hierarchical data? For instance, I have
> generators[1], each of which has a name, a fuel and one or more
> incremental heat rate curves. Each fuel has a name, UOM, heat content,
> and price. Each incremental cost curve has a name, and a series of
> ordered pairs (representing a piecewise linear curve).
>
> Can CSV files model this sort of situation?

The short answer is no. CSV files represent spreadsheet row-column
values with nothing fancier such as formulas or other redirections.

CSV is quite good as a lowest common denominator exchange format. I say
quite because I would characterize it by 8 attributes and you need to
pick a dialect such as MS Excel which sets out what those are. XML and
JSON are controlled much better. You can easily verify that you conform
to those and guarantee that *any* conformant parser can read your
content. XML is more powerful in that repect than JSON in that you can
define and enforce schemas. In your case the fuel name, UOM, etc. can be
validated with standard tools. In JSON all that checking is entirely
handled by the consuming program(s).

>> As in all such cases it is a matter of choosing the most apropriate tool
>> for the job in hand.
>
> Naturally. That's what I'm exploring.

You might also like to consider HDF5. It is targeted at large volumes of
scientific data and its capabilities are well above what you need.
MATLAB, Octave and Scilab use it as their native format. PyTables and
h2py provide Python/NumPy bindings to it.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-22 Thread Pete Forman
Jon Ribbens  writes:

> On 2021-09-21, Pete Forman  wrote:
>> CSV is quite good as a lowest common denominator exchange format. I
>> say quite because I would characterize it by 8 attributes and you
>> need to pick a dialect such as MS Excel which sets out what those
>> are. XML and JSON are controlled much better. You can easily verify
>> that you conform to those and guarantee that *any* conformant parser
>> can read your content. XML is more powerful in that repect than JSON
>> in that you can define and enforce schemas. In your case the fuel
>> name, UOM, etc. can be validated with standard tools. In JSON all
>> that checking is entirely handled by the consuming program(s).
>
> That's not true. You can use "JSON Schema" to create a schema for
> validating JSON files, and there appear to be at least four
> implementations in Python.

Fair point. It has been a while since I looked at JSON schemas and they
were rather less mature then.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lxml and xpath(?)

2016-10-27 Thread Pete Forman
Peter Otten <__pete...@web.de> writes:

> root = etree.fromstring(s)
> for server in root.xpath("./server"):
> servername = server.xpath("./name/text()")[0]

When working with lxml I prefer to use this Python idiom.

servername, = server.xpath("./name/text()")

That enforces a single result. The original code will detect a lack of
results but if the query returns multiple results when only one is
expected then it silently returns the first.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


PEP 393 vs UTF-8 Everywhere

2017-01-20 Thread Pete Forman
Can anyone point me at a rationale for PEP 393 being incorporated in
Python 3.3 over using UTF-8 as an internal string representation? I've
found good articles by Nick Coghlan, Armin Ronacher and others on the
matter. What I have not found is discussion of pros and cons of
alternatives to the old narrow or wide implementation of Unicode
strings.

ISTM that most operations on strings are via iterators and thus agnostic
to variable or fixed width encodings. How important is it to be able to
get to part of a string with a simple index? Just because old skool
strings could be treated as a sequence of characters, is that a reason
to shoehorn the subtleties of Unicode into that model?

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 393 vs UTF-8 Everywhere

2017-01-20 Thread Pete Forman
Chris Kaynor  writes:

> On Fri, Jan 20, 2017 at 2:35 PM, Pete Forman  wrote:
>> Can anyone point me at a rationale for PEP 393 being incorporated in
>> Python 3.3 over using UTF-8 as an internal string representation?
>> I've found good articles by Nick Coghlan, Armin Ronacher and others
>> on the matter. What I have not found is discussion of pros and cons
>> of alternatives to the old narrow or wide implementation of Unicode
>> strings.
>
> The PEP itself has the rational for the problems with the narrow/wide
> idea, the quote from https://www.python.org/dev/peps/pep-0393/: There
> are two classes of complaints about the current implementation of the
> unicode type:on systems only supporting UTF-16, users complain that
> non-BMP characters are not properly supported. On systems using UCS-4
> internally (and also sometimes on systems using UCS-2), there is a
> complaint that Unicode strings take up too much memory - especially
> compared to Python 2.x, where the same code would often use ASCII
> strings (i.e. ASCII-encoded byte strings). With the proposed approach,
> ASCII-only Unicode strings will again use only one byte per character;
> while still allowing efficient indexing of strings containing non-BMP
> characters (as strings containing them will use 4 bytes per
> character).
>
> Basically, narrow builds had very odd behavior with non-BMP
> characters, namely that indexing into the string could easily produce
> mojibake. Wide builds used quite a bit more memory, which generally
> translates to reduced performance.

I'm taking as a given that the old way was often sub-optimal in many
scenarios. My questions were about the alternatives, and why PEP 393 was
chosen over other approaches.

>> ISTM that most operations on strings are via iterators and thus
>> agnostic to variable or fixed width encodings. How important is it to
>> be able to get to part of a string with a simple index? Just because
>> old skool strings could be treated as a sequence of characters, is
>> that a reason to shoehorn the subtleties of Unicode into that model?
>
> I think you are underestimating the indexing usages of strings. Every
> operation on a string using UTF8 that contains larger characters must
> be completed by starting at index 0 - you can never start anywhere
> else safely. rfind/rsplit/rindex/rstrip and the other related reverse
> functions would require walking the string from start to end, rather
> than short-circuiting by reading from right to left. With indexing
> becoming linear time, many simple algorithms need to be written with
> that in mind, to avoid n*n time. Such performance regressions can
> often go unnoticed by developers, who are likely to be testing with
> small data, and thus may cause (accidental) DOS attacks when used on
> real data. The exact same problems occur with the old narrow builds
> (UTF16; note that this was NOT implemented in those builds, however,
> which caused the mojibake problems) as well - only a UTF32 or PEP393
> implementation can avoid those problems.

I was asserting that most useful operations on strings start from index
0. The r* operations would not be slowed down that much as UTF-8 has the
useful property that attempting to interpret from a byte that is not at
the start of a sequence (in the sense of a code point rather than
Python) is invalid and so quick to move over while working backwards
from the end.

The only significant use of an index dereference that I could come up
with was the result of a find() or index(). I put out this public
question so that I could be enclued as to other uses. My personal
experience is that in most cases where I might consider find() that I
end up using re and use the return from match groups which has copies of
the (sub)strings that I want.

> Note that from a user (including most developers, if not almost all),
> PEP393 strings can be treated as if they were UTF32, but with many of
> the benefits of UTF8. As far as I'm aware, it is only developers
> writing extension modules that need to care - and only then if they
> need maximum performance, and thus cannot convert every string they
> access to UTF32 or UTF8.

PEP 393 already says that "the specification chooses UTF-8 as the
recommended way of exposing strings to C code".

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 393 vs UTF-8 Everywhere

2017-01-20 Thread Pete Forman
MRAB  writes:

> As someone who has written an extension, I can tell you that I much
> prefer dealing with a fixed number of bytes per codepoint than a
> variable number of bytes per codepoint, especially as I'm also
> supporting earlier versions of Python where that was the case.

At the risk of sounding harsh, if supporting variable bytes per
codepoint is a pain you should roll with it for the greater good of
supporting users.

PEP 393 / Python 3.3 required extension writers to revisit their access
to strings. My explicit question was about why PEP 393 was adopted to
replace the deficient old implementations rather than another approach.
The implicit question is whether a UTF-8 internal representation should
replace that of PEP 393.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 393 vs UTF-8 Everywhere

2017-01-21 Thread Pete Forman
Steve D'Aprano  writes:

> [...]
> Another factor which I didn't see discussed anywhere is that Python
> strings treat surrogates as normal code points. I believe that would
> be troublesome for a UTF-8 implementation:
>
> py> '\uDC37'.encode('utf-8')
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeEncodeError: 'utf-8' codec can't encode character '\udc37' in
> position 0: surrogates not allowed
>
> but of course with a UCS-2 or UTF-32 implementation it is trivial: you
> just treat the surrogate as another code point like any other.

Thanks for a very thorough reply, most useful. I'm going to pick you up
on the above, though.

Surrogates only exist in UTF-16. They are expressly forbidden in UTF-8
and UTF-32. The rules for UTF-8 were tightened up in Unicode 4 and RFC
3629 (2003). There is CESU-8 if you really need a naive encoding of
UTF-16 to UTF-8-alike.

py> low = '\uDC37'

is only meaningful on narrow builds pre Python 3.3 where the user must
do extra to correctly handle characters outside the BMP.

-- 
Pete Forman
https://payg-petef.rhcloud.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 393 vs UTF-8 Everywhere

2017-01-21 Thread Pete Forman
Marko Rauhamaa  writes:

>> py> low = '\uDC37'
>
> That should raise a SyntaxError exception.

Quite. My point was that with older Python on a narrow build (Windows
and Mac) you need to understand that you are using UTF-16 rather than
Unicode. On a wide build or Python 3.3+ then all is rosy. (At this point
I'm tempted to put in a winky emoji but that might push the internal
representation into UCS-4.)

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread Pete Forman
Why is it that Python continues to use a fixed width font and therefore
specifies the maximum line width as a character count?

An essential part of the language is indentation which ought to continue
to mandate that lines start with a multiple of 4 em worth of space (or
some other size or encode with hard tabs, that is not germane to my
question). The content of the line need not be bound by the rules needed
to position its start.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread Pete Forman
Ian Kelly  writes:

> On Mon, Apr 18, 2016 at 3:14 PM, Pete Forman  wrote:
>> Why is it that Python continues to use a fixed width font and
>> therefore specifies the maximum line width as a character count?
>>
>> An essential part of the language is indentation which ought to
>> continue to mandate that lines start with a multiple of 4 em worth of
>> space (or some other size or encode with hard tabs, that is not
>> germane to my question). The content of the line need not be bound by
>> the rules needed to position its start.
>
> How many spaces is "4 em worth"? How would you incorporate that into
> the Python compiler or a linter without needing to know what
> particular font the programmer is using? What happens when another
> programmer reviews the code using a different font and finds that
> there is only 3.5em worth of space? Do we descend into Calibri /
> Verdana line-length edit wars?

4 em is what PEP 8 implies, with the implicit use of a monospaced font.
I was trying to convey that the mechanics of indentation was not
relevant to my question about why Python and indeed other programming
languages are rarely edited or viewed with proportional fonts. The
programmer, other humans reading the source and the interpreter need to
be able to discern structure by the indentation. It is what follows the
indentation that interests me.

The current Python interpreter will happily digest a combination of
spaces and hard tabs as long as consistency rules are obeyed.

My question was intended to concentrate on the presentation after the
leading whitespace.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido sees the light: PEP 8 updated

2016-04-19 Thread Pete Forman
Rustom Mody  writes:

> On Tuesday, April 19, 2016 at 6:49:34 AM UTC+5:30, sohcatoa wrote:
>> On Monday, April 18, 2016 at 2:14:17 PM UTC-7, Pete Forman wrote:
>> > Why is it that Python continues to use a fixed width font and therefore
>> > specifies the maximum line width as a character count?
>> >
>> > An essential part of the language is indentation which ought to continue
>> > to mandate that lines start with a multiple of 4 em worth of space (or
>> > some other size or encode with hard tabs, that is not germane to my
>> > question). The content of the line need not be bound by the rules needed
>> > to position its start.
>> >
>> > --
>> > Pete Forman
>>
>> "Why is it that Python continues to use a fixed width font "
>>
>> This guy is trolling, right?

No, it is a genuine question. It applies to computer langauges in
general but this thread is about PEP 8 so I framed it for Python.
I was not proposing a change to the langauge.


> See elastic tabstops: http://nickgravgaard.com/elastic-tabstops/

I like that Nick separates out the concept of alignment with implicit
semantics from the n spaces v tabs arguments. My question asks why
monospace is used for the text.

> And more generally that programmers sticking to text when rest of
> world has moved on is rather backward:
> http://blog.languager.org/2012/10/html-is-why-mess-in-programming-syntax.html

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: name for project of a cross version disassembler, and unmarshal program

2016-05-22 Thread Pete Forman
rocky  writes:

> I'm looking for a good name for a relatively new project I'll put on pypy.
>
> I've been working on a module to disassemble Python bytecode from many
> versions of Python. (Right now 2.3 .. 3.5 bytecode, largely works.)
>
> Of course, in order to do that you also need routines to unmarshal
> bytecode. So that's in there as well.
>
> In the future, I may could add a marshaler and an assembler to Python
> bytecode. I know, this is kind of perverse.
>
> At any rate the name I've been using is "pyxdis". See
> https://github.com/rocky/python-pyxdis.
>
> In the past I've been told by Polish-speaking people that my names are
> hard to pronounce. (If you've ever heard any Polish tongue twisters,
> you'll know that this really hurts.)
>
> Any suggestions for a better name?

relipmoc

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: name for project of a cross version disassembler, and unmarshal program

2016-05-23 Thread Pete Forman
Rustom Mody  writes:

> On Monday, May 23, 2016 at 1:38:41 PM UTC+5:30, rocky wrote:
>> On Monday, May 23, 2016 at 2:17:07 AM UTC-4, Pete Forman wrote:
>> > rocky  writes:
>> >
>> > > I'm looking for a good name for a relatively new project I'll put
>> > > on pypy.
>> > >
>> > > I've been working on a module to disassemble Python bytecode from
>> > > many versions of Python. (Right now 2.3 .. 3.5 bytecode, largely
>> > > works.)
>> > >
>> > > Of course, in order to do that you also need routines to
>> > > unmarshal bytecode. So that's in there as well.
>> > >
>> > > In the future, I may could add a marshaler and an assembler to
>> > > Python bytecode. I know, this is kind of perverse.
>> > >
>> > > At any rate the name I've been using is "pyxdis". See
>> > > https://github.com/rocky/python-pyxdis.
>> > >
>> > > In the past I've been told by Polish-speaking people that my
>> > > names are hard to pronounce. (If you've ever heard any Polish
>> > > tongue twisters, you'll know that this really hurts.)
>> > >
>> > > Any suggestions for a better name?
>> >
>> > relipmoc
>> >
>> > --
>> > Pete Forman
>>
>> Interesting. (For those who are slow like myself, it is "compile"
>> backwards.

Well it's actually "compiler" but I'd not be offended if you want to
develop the idea.

> Heh! I also wondered...
> And if you are into that kinda stuff, how about:   ɔoɯdᴉlǝ  ? (¿)

I did consider suggesting that but it falls foul of PEP 426. PyPI is not
yet ready to dip its toes outside of the confines of ASCII. [wry smile
emoji deleted]

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-05-23 Thread Pete Forman
Ian Kelly  writes:

> On Mon, May 23, 2016 at 8:29 AM, Ben Bacarisse  wrote:
>> Ian Kelly  writes:
>>
>>> On Mon, May 23, 2016 at 2:09 AM, Steven D'Aprano
>>>  wrote:
>>>> Are you saying that the Egyptians, Babylonians and Greeks didn't
>>>> know how to work with fractions?
>>>>
>>>> http://mathworld.wolfram.com/EgyptianFraction.html
>>>>
>>>> http://nrich.maths.org/2515
>>>>
>>>> Okay, it's not quite 4000 years ago. Sometimes my historical sense
>>>> of the distant past is a tad inaccurate. Shall we say 2000 years
>>>> instead?
>>>
>>> Those links give dates of 1650 BC and 1800 BC respectively, so I'd
>>> say your initial guess was closer.
>>
>> Right, but this is to miss the point. Let's say that 4000 years have
>> defined 1/3 to be one third, but Python 3 (as do many programming
>> languages) defines 1/3 to be something very very very very close to
>> one third, and *that* idea is very very very very new! It's
>> unfortunate that the example in this thread does not illustrate the
>> main problem of shifting to binary floating point, because 1/2
>> happens to be exactly representable.
>
> I'm not going to dig back through the thread, but my recollection is
> that's exactly why that example was chosen. Since 1/2 can be
> represented exactly as a float, it *should* be represented as a float.
> Picking another value (0) that isn't even close to the exact value of
> 1/2 isn't helping anybody.

Something else which I do not think has been stated yet in this thread
is that floating point is an inexact representation. Just because
integers and binary fractions have an exact correspondence we ought not
to be affording them special significance. Floating point 1 is not the
integer 1, it stands for a range of numbers some fraction either side of
1.

There are other ways of handling non-integral numbers, such as fixed
point, rational and unum. However current computing hardware is very
much oriented to floating point, IEEE in particular.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-05-23 Thread Pete Forman
Ian Kelly  writes:

> On Mon, May 23, 2016 at 12:16 PM, Pete Forman  wrote:
>> Something else which I do not think has been stated yet in this
>> thread is that floating point is an inexact representation. Just
>> because integers and binary fractions have an exact correspondence we
>> ought not to be affording them special significance. Floating point 1
>> is not the integer 1, it stands for a range of numbers some fraction
>> either side of 1.
>
> This is not the case. Floating point 1 means exactly 1, no more and no
> less. Results that aren't exactly representable get rounded to values
> that are, but this does not imply that the value once rounded is
> inexact. The value that 1/3 gets rounded to is exactly equal to
> 6004799503160661 / 18014398509481984, no more and no less.
>
> Treating floating point values as inexact would require an
> accumulation of the range of error. Otherwise, it would no longer be
> correct to say that 1.0 * 1.0 == 1.0. The result could with equal
> correctness be the next floating point number after 1.0, or the
> previous value before 1.0. Continue multiplying by 1.0 and the error
> creeps larger and larger. The defined result of the operation,
> however, is the exact value 1.0.

Let us for the sake of argument consider a floating point representation
that has one decimal point of precision. It is easier to talk about than
the IEEE double precision used in Python.

If you are talking about the multiplicative identity element then 1.0 is
exactly unity and repeated multiplication will not change the result.
However I am coming from scientific measurements where 1.0 is the stored
value for observations between 0.95 and 1.05. If I wish to correlate two
signals that were 1.03 and 1.04 at higher precision then 1.1 is actually
a reasonable value for their "correct" product, even though 1.0 is what
is prescribed by IEEE-style rules because they are both stored as 1.0.

I agree that errors tend to creep ever larger. IEEE rounding rules seek
to minimize the error of the result but management of the accumulated
error is up to the scientist / programmer, it is not part of the IEEE
arithmetic.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-05-24 Thread Pete Forman
Gregory Ewing  writes:

> Pete Forman wrote:
>> However I am coming from scientific measurements where 1.0 is the
>> stored value for observations between 0.95 and 1.05.
>
> You only know that because you're keeping some extra information in
> your head about what the 1.0 stored in your computer represents. It's
> not inherent in the value itself.

No, that is a real case. Floating point hardware can hold intermediate
values in 80 bit registers before writing the double precision result to
8 bytes of memory. There are compiler switches available to enforce
strict IEEE conformance and discard the intermediate guard digits. By
adhering to those rules the results are predictable (repeatable on other
hardware) but less accurate mathematically speaking.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Format a timedelta object

2016-05-27 Thread Pete Forman
Steven D'Aprano  writes:

> On Thu, 26 May 2016 03:28 pm, Zachary Ware wrote:
>
>> On Thu, May 26, 2016 at 12:16 AM, Steven D'Aprano
>>  wrote:
>>> I have a timedelta object, and I want to display it in a nice
>>> human-readable format like 03:45:17 for "three hours, forty five minutes,
>>> 17 seconds".
>>>
>>> Is there a standard way to do this?
>>
>>>>> timedelta(100)
>>datetime.timedelta(100)
>>>>> str(timedelta(seconds=100))
>>'0:01:40'
>>>>> str(timedelta(hours=100))
>>'4 days, 4:00:00'
>>
>> (I recently spent *way* too long trying to figure out how to properly
>> format the thing before being reminded that a plain str call gives
>> exactly what I was after.)
>
> Thanks Zach. Unfortunately, the format is not quite how I want it, so I
> guess I'll have to extract the H:M:S fields manually from the seconds.

It might be useful if timedelta were to get an isoformat() method. ISO
8601 specifies formats for durations; most people are familiar only with
the date amd time formats. There are variations available but PnDTnHnMnS
is probably the best. The biggest timedelta unit is days. Years and
months are not appropriate.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method Chaining

2016-06-18 Thread Pete Forman
Rustom Mody  writes:

> On Friday, June 17, 2016 at 2:58:19 PM UTC+5:30, Steven D'Aprano wrote:
>> On Fri, 17 Jun 2016 06:13 pm, Ned Batchelder wrote:
>>
>> > To me, it's a toss-up. The chained version is nice in that it
>> > removes the repetition of "g". But the unchained version is more
>> > explicit, and avoids the awkward parenthesis.
>> >
>> > I think I would lean toward the unchained version. Clearly tastes
>> > can differ.
>>
>> Indeed. For what it's worth, I'm ever-so-slightly leaning towards
>> Lawrence's taste here.
>
> More than 'slightly' out here!
> One thing about python OOP that irritates me is the 'self.' clutter.
> With a Pascal/VB style with-statement its naturally taken care of
>
> Yeah I know there is this FAQ:
> https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments
>
> I consider it bogus if we allow with to mean something like:
> https://msdn.microsoft.com/en-us/library/wc500chb.aspx

One subtle difference between your two citations is that VB uses a
leading dot. Might that lessening of ambiguity enable a future Python to
allow this?

class Foo:
def .set(a):  # equivalent to def set(self, a):
.a = a# equivalent to self.a = a

Unless it is in a with statement

with obj:
.a = 1# equivalent to obj.a = 1
.total = .total + 1   # obj.total = obj.total + 1

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: value of pi and 22/7

2016-06-18 Thread Pete Forman
Lawrence D’Oliveiro  writes:

> On Saturday, March 19, 2011 at 3:16:41 AM UTC+13, Grant Edwards wrote:
>>
>> On 2011-03-18, peter wrote:
>>
>>> The Old Testament (1 Kings 7,23) says ... "And he made a molten sea,
>>> ten cubits from the one brim to the other: it was round all about, and
>>> his height was five cubits: and a line of thirty cubits did compass it
>>> round about. ".  So pi=3.  End Of.
>>
>> There's nothing wrong with that value.  The measurements were given
>> with one significant digit, so the ratio of the two measurements
>> should only have one significant digit.
>
> I’m not sure how you can write “30” with one digit...

>>> int('U', 36)
30

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method Chaining

2016-06-18 Thread Pete Forman
Joonas Liik  writes:

> On 18 June 2016 at 15:04, Pete Forman  wrote:
>> Rustom Mody  writes:
>>
>>> On Friday, June 17, 2016 at 2:58:19 PM UTC+5:30, Steven D'Aprano wrote:
>>>> On Fri, 17 Jun 2016 06:13 pm, Ned Batchelder wrote:
>>>>
>>>> > To me, it's a toss-up. The chained version is nice in that it
>>>> > removes the repetition of "g". But the unchained version is more
>>>> > explicit, and avoids the awkward parenthesis.
>>>> >
>>>> > I think I would lean toward the unchained version. Clearly tastes
>>>> > can differ.
>>>>
>>>> Indeed. For what it's worth, I'm ever-so-slightly leaning towards
>>>> Lawrence's taste here.
>>>
>>> More than 'slightly' out here!
>>> One thing about python OOP that irritates me is the 'self.' clutter.
>>> With a Pascal/VB style with-statement its naturally taken care of
>>>
>>> Yeah I know there is this FAQ:
>>> https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments
>>>
>>> I consider it bogus if we allow with to mean something like:
>>> https://msdn.microsoft.com/en-us/library/wc500chb.aspx
>>
>> One subtle difference between your two citations is that VB uses a
>> leading dot. Might that lessening of ambiguity enable a future Python to
>> allow this?
>>
>> class Foo:
>> def .set(a):  # equivalent to def set(self, a):
>> .a = a# equivalent to self.a = a
>>
>> Unless it is in a with statement
>>
>> with obj:
>> .a = 1# equivalent to obj.a = 1
>> .total = .total + 1   # obj.total = obj.total + 1
>>
>> --
>> Pete Forman
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
> the leading dot does not resolve the ambiguity that arises from:
>
> with ob_a:
> with ob_b:
> .attr_c = 42 # which object are we modifying right now?
>
> also refer to "javascript the bad parts" about all the edege cases
> that python would surely face.
> also with is allready used for context managers..

Yes, I ought not to have lumped in the with proposal with that for self.
Python's design FAQ clearly explains why the language does not need that
form of "with".

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Method Chaining

2016-06-19 Thread Pete Forman
Rustom Mody  writes:

> On Saturday, June 18, 2016 at 5:34:30 PM UTC+5:30, Pete Forman wrote:
>> Rustom Mody  writes:
>> [snip]
>>
>> One subtle difference between your two citations is that VB uses a
>> leading dot. Might that lessening of ambiguity enable a future Python to
>> allow this?
>>
>> class Foo:
>> def .set(a):  # equivalent to def set(self, a):
>> .a = a# equivalent to self.a = a
>>
>
> Chuckle! Heck Why not?!
> But no I did not think of this

Why stop there? Another long standing bugbear can be addressed with
this.

class Foo:
def .set(.a, b)  # equivalent to def set(self, a): self.a = a
.c += b  # equivalent to self.c += b

Explicitly, that is three new syntactic items.

1) . before a method name elides the first argument of self
2) . before an argument is shorthand for assign to a member
3) . before a variable in a method body replaces self.

Earlier I had proposed a new use of "with" that would have changed the
binding in (3) from self to something else. That was not a good idea for
two reasons. Python already provides a reasonable way to achieve that,
as described in the design FAQ. The second reason is that it subverts
the current "with" statement which mandates its with_item to be a
context expression. "as target" is optional and so syntactic
discrimination is not possible.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: best text editor for programming Python on a Mac

2016-06-19 Thread Pete Forman
Joel Goldstick  writes:

> On Sat, Jun 18, 2016 at 8:12 PM, Lawrence D’Oliveiro
>  wrote:
>> On Sunday, June 19, 2016 at 11:07:23 AM UTC+12, Michael Torrie wrote:
>>>
>>> On 06/17/2016 05:52 PM, Chris via Python-list wrote:
>>>>
>>>> Any suggestions for a good open source text editor for the Mac out
>>>> there?  For now, I am going to stick with vim.
>>>
>>> Good choice.
>>
>> The trouble with vim/vi/whatever, is that it doesn’t work like any
>> other editor on Earth.
>>
>> Pull up any old GUI-based editor you like, for example Windows
>> (shudder) Notepad. If there are N characters in your file, then the
>> insertion point can be placed at N + 1 positions: in-between two
>> adjacent characters, or before the first character, or after the last
>> character. And this makes sense: anything you type is inserted at the
>> insertion point. All rational text editors (and word processors) work
>> this way.
>>
>> But not vi/vim. It only lets you place your cursor *on* a character,
>> not *in-between* characters. That’s why you need two separate
>> insertion commands, insert-before and insert-after. And one of those
>> has the interesting side effect where, if you exit insertion mode
>> without inserting anything, it doesn’t put you back in the same
>> position as before. Why?
>>
>> As to why you need insertion commands at all, that’s another thing...
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
> I personally love vim.  But its clearly an acquired taste.  When you
> get good at it its pretty amazing -- and no mouse.  The other thing
> about vim is that it is on every linux system, so you don't have to
> load your editor if you are ssh-ing to some machine

Both emacs and vim are powerful tools in the hands of experienced users
but I would recommend neither to someone starting out who is just
looking for a code-aware editor.

Emacs and vim are much more than editors. I'm composing this message
using Emacs/Gnus on a Mac. TRAMP is invaluable to me for my daily work.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python packages listed in PyPI

2016-07-20 Thread Pete Forman
Rayne  writes:

> May I know if the Python packages listed on the PyPI page
> (https://pypi.python.org/pypi) are OS-independent? That is, do I
> download and install the same package on both Windows and Linux

The simple answer is yes. pip install will find the appropriate
implementation for your OS and version of Python.

If the package is pure Python then it will be the same across OS. If
there is some binary content then PyPI will deliver the correct wheel
(precompiled) or C/C++ source. The latter generally builds OOTB on
Linux but needs extra work on Windows as that does not bundle a
compiler.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python packages listed in PyPI

2016-07-21 Thread Pete Forman
On 21 July 2016 at 07:28, Rayne  wrote:

> Thanks! One more question: Does "pip install" require Internet to work? Or
> are all implementations already contained in the packages and so do not
> require additional downloads?
>

pip install is downloading from https://pypi.python.org so yes you do
need internet access. Having said that there are a couple of ways to
feed pip. You can run a local pypi server to host previously downloaded
packages or tell pip to install from a file. "pip help install"

Automatic handling of additional downloads is automatic in pip. If the
package you are installing requires some other packages then it will
install those too.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-24 Thread Pete Forman
Robin Becker  writes:

> On 22/01/2019 19:00, Schachner, Joseph wrote:
> ..
>> For anyone who has moved a substantial bunch of Python 2 to Python 3,
>> can you please reply with your experience? Did you run into any
>> issues? Did 2to3 do its job well, or did you have to review its
>> output to eliminate some working but silly thing?
>>
> ,..
> I did the port of reportlab (www.reportlab.com) from code supporting
> 2.x only x>=3 to a version which supported 2.7.z & >=3.3. The
> reportlab toolkit was then about 14 years old and had (and still has
> lots of cruft). The port effort began 20130215 and ended 20140326 ie
> 13 months. There were 333 commits on the branch. I used 2to3, but not
> six. Because we needed to maintain 2.7 and >=3.3 there were quite a
> few issues related to simple things like iterkeys/values/items <-->
> keys/values/items removal of xrange etc etc.
>
> Maintaining compatible extensions is also hard. Pdf production
> requires byte output and was already quite messy because reportlab
> supported both utf8 and unicode inputs; it hasn't got a lot easier.
>
> As for performance the 3.x runs were generally slower than 2.7, but I
> think that situation has changed with 3.6 & 3.7 (for the reportlab
> tests on windows 2.7 takes 68.7", 3.4 83.8", 3.5 77.0", 3.6 61.5" &
> 3.7 60.9").
>
> At some point reportlab will be made 3.x only which will require more
> effort.

Packages like reportlab with a need to support both Python 2 and 3 end
up with the worst of both worlds. The initial drive for Py3k was to drop
cruft that had accumulated over the years. Mixing old and new hampers
your ability to write clean 3 code.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Replacement for pygtk?

2020-09-07 Thread Pete Forman
Akkana Peck  writes:

> Grant Edwards writes:
>>  * PyQt -- I run Gtk-centric Linux systems, and the second you try to
>>use one Qt widget, it always seems to pull in hundreds of packages
>>that take a week to build.
>
> I haven't generally found that about PyQt. Most KDE apps do pull in
> hundreds of packages, but I haven't had to install that many just to
> use PyQt.

Once you have one Qt app in a Gtk DE, or vice versa, then you have taken
most of the hit for packages. I doubt that many people run pure versions
of either.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is Expresiveness in a Computer Language?

2005-07-10 Thread Pete Barrett
On 10 Jul 2005 02:57:04 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote:

>Similarly, in computer languages, expressiveness is significant with
>respect to semantics, not syntactical variation.
>
It may just be me, but I tend to think of a computer language as a
tool for directing computers to perform specific actions. Do we talk
about the expressiveness of a spade?

There's a similar concept in the 'possible uses' of a tool (a spade is
an excellent tool for digging the garden, but you wouldn't use it to
clean your teeth; you *could* use a toothbrush to dig the garden, but
you wouldn't if a spade was available). Similarly with computer
languages - some are better for certain tasks than others, but I don't
think 'expressiveness' is the way to describe that.

Pete Barrett
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Python 2.4 Quick Reference available

2005-02-19 Thread Pete Havens
The is awesome! Thanks. I did notice one thing while reading it. In the
"File Object" section, it states:

"Created with built-in functions open() [preferred] or its alias
file()."

...this seems to be the opposite of the Python documentation:

"The file() constructor is new in Python 2.2. The previous spelling,
open(), is retained for compatibility, and is an alias for file()."

...but I'm picking nits, because this is a fantastic piece of work and
will be very useful to me. Thanks again!

-- 
http://mail.python.org/mailman/listinfo/python-list


UML modeling tools

2005-03-02 Thread Pete Brunet

What are your recommendations for a
UML modeling tool with these requirements (or something that comes close):
- low learning curve, easy to use, good
performance, high quality
- runs on Linux(FC3) and Win(XP) - or
JVM
- low in price <$500
- can export/print images in various
formats including HTML
- can round trip with Python (and C/C++)
code
- well recommended by other users

Thanks, Pete-- 
http://mail.python.org/mailman/listinfo/python-list

Re: injecting "set" into 2.3's builtins?

2005-03-14 Thread Pete Forman
Skip Montanaro <[EMAIL PROTECTED]> writes:

 > Stephen> I have:
 > Stephen> try:
 > Stephen> set
 > Stephen> except NameError:
 > Stephen> from sets import Set as set
>
 > Stephen> in my code in a few places.
>
 > Yes, but then pychecker complains about a statement with no apparent effect,
 > hence the extra verbiage.
>
 > My question wasn't about a less ugly way to type what I type now.  It was
 > about whether injecting "set" into the builtins (so I can dispense with the
 > above cruft altogether) is likely to cause problems.  I think not, certainly
 > based on what little surveying I've done at work.  I was hoping someone else
 > had already tried this and could report on their experience.

This is what I use to allow my 2.4 code to run on 2.3.

if not 'set' in dir(__builtins__):
from sets import Set as set, ImmutableSet as frozenset

-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   opinion of Schlumberger, Baker
http://petef.port5.com   -./\.-   Hughes or their divisions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Makeing TopLevel Modal ?

2005-04-03 Thread Pete Moscatt
Hi all,

I want to make a dialog (using Tk Toplevel) but need it to be modal.  Is
this possible using Tk ?

Show below is an example how I am calling the custom dialog:

class main: 
def __init__(self,parent):

top = self.top = Toplevel(parent)
top.title("Server Settings")
top.minsize(width=230,height=270)
top.maxsize(width=230,height=270)   





Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Testing for EOF ?

2005-04-04 Thread Pete Moscatt
I am reasonably new to python and am trying to read several lines of text
from an open file.

Typically in other languages I used to use code like:

while not EOF()
  read_text_in
  ...


How is this achieved with python ?

Regards
Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Placing Toplevel over the parent ?

2005-04-05 Thread Pete Moscatt
When calling a dialog box using the Toplevel widget, how do I place it over
the calling parent ?

Currently when I call the dialog it appears to the side of the calling
parent.

Pete

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guessing the encoding from a BOM

2014-01-17 Thread Pete Forman
Rustom Mody  writes:

> On Friday, January 17, 2014 7:10:05 AM UTC+5:30, Tim Chase wrote:
>> On 2014-01-17 11:14, Chris Angelico wrote:
>> > UTF-8 specifies the byte order
>> > as part of the protocol, so you don't need to mark it.
>
>> You don't need to mark it when writing, but some idiots use it
>> anyway.  If you're sniffing a file for purposes of reading, you need
>> to look for it and remove it from the actual data that gets returned
>> from the file--otherwise, your data can see it as corruption.  I end
>> up with lots of CSV files from customers who have polluted it with
>> Notepad or had Excel insert some UTF-8 BOM when exporting.  This
>> means my first column-name gets the BOM prefixed onto it when the
>> file is passed to csv.DictReader, grr.
>
> And its part of the standard:
> Table 2.4 here
> http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf

It would have been nice if there was an eighth encoding scheme defined
there UTF-8NB which would be UTF-8 with BOM not allowed.
-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guessing the encoding from a BOM

2014-01-17 Thread Pete Forman
Chris Angelico  writes:
> On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence  
> wrote:
>> Slight aside, any chance of changing the subject of this thread, or even
>> ending the thread completely?  Why?  Every time I see it I picture Inspector
>> Clouseau, "A BOM!!!" :)
>
> Special delivery, a berm! Were you expecting one?

Endian detection: Does my BOM look big in this?

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pytz question: GMT vs. UTC

2014-02-02 Thread Pete Forman
Grant Edwards  writes:

> On 2014-01-30, wxjmfa...@gmail.com  wrote:
>
>> The temperature unit is the "Kelvin", not the "Degree Kelvin".
>> One writes: 0 K, 275.15 K
>
> And remember to say "Kelvins" not "Kelvin" when speaking about
> temperatures other than 1 K.

And remember to write kelvins. SI units named after people such as
kelvin, watt and pascal are lower case while their symbols have a
leading capital: K, W, Pa.
-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using virtualenv to bypass sudoer issues

2014-02-10 Thread Pete Forman
Jean-Michel Pichavant  writes:

> Thank you all for you insights.
>
> I'll probably go with virtualenv, I'll be able to distribute it among
> the team.
> There's still one point worrying me though:
> We're doing a lot a remote execution. We're using "execnet"
> http://codespeak.net/execnet/, and I'm not sure it can be compatible
> with virtualenv. execnet working at the "python level" I don't see how
> I can execute shell stuff before.
>
> I had a look at fabric http://docs.fabfile.org/en/1.8/, and it looks
> like it can handle virtual env (anyone confirm?).
>
> Has someone already successfully remotely activated a venv then
> execute a python scripts within that env, getting back the
> stdout/stderr ?
>
> I'm afraid right now that switching to venv would mean switching from
> execnet to fabric as well (I hate redoing stuff that works :-/ ).

Call the venv version of python and activation is handled.
E.g. in a fabfile

myenv/bin/python myscript.py

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting dictionary by datetime value

2014-02-10 Thread pete suchsland
How about make it simple by using sorted(a.values()) ...

>>> a = {}
>>> a['first'] = datetime.datetime.now()
>>> a['second'] = datetime.datetime.now()
>>> a['third'] = datetime.datetime.now()
>>> a['forth'] = datetime.datetime.now()
>>> a['fifth'] = datetime.datetime.now()

>>> sorted(a.values())
[datetime.datetime(2014, 2, 10, 19, 24, 35, 163585), datetime.datetime(2014, 2, 
10, 19, 24, 53, 244532), datetime.datetime(2014, 2, 10, 19, 25, 9, 483683), 
datetime.datetime(2014, 2, 10, 19, 25, 25, 581743), datetime.datetime(2014, 2, 
10, 19, 25, 37, 789907)]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Calculating longitudinal acceleration, lateral acceleration and normal acceleration

2016-01-24 Thread Pete Dowdell

On 24/01/16 07:27, Robert James Liguori wrote:

Is there a python library to calculate longitudinal acceleration, lateral 
acceleration and normal acceleration?


Might be rocket science...

pd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Continuing indentation

2016-03-02 Thread Pete Forman
Chris Angelico  writes:

> On Thu, Mar 3, 2016 at 10:46 AM,   wrote:
>> On Wednesday, March 2, 2016 at 3:44:07 PM UTC-5, Skip Montanaro wrote:
>>>
>>> if (some_condition and
>>> some_other_condition and
>>> some_final_condition):
>>> play_bingo()
>>
>> How about:
>>
>>   continue_playing = (
>>   some_condition and
>>   some_other_condition and
>>   some_final_condition
>>   )
>>
>>   if continue_playing:
>>   play_bingo()
>>
>> or:
>>
>>   play_conditions = [
>>   some_condition,
>>   some_other_condition,
>>   some_final_condition,
>>   ]
>>
>>   if all(play_conditions):
>>   play_bingo()
>
> Those feel like warping your code around the letter of the law,
> without really improving anything.

I beg to differ. If an expression is long or complex then splitting it
up and, importantly, giving good names to the intermediates makes the
code clearer. That advice is not restricted to if statements.

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip3.x error using LIST instead of list

2014-02-12 Thread Pete Forman
Dave Angel  writes:

>  Mark Lawrence  Wrote in message:
>>
>>
>> No matter what I try I can't get the subcommands in lower-case when I
>> have caps lock on, is there a simple work-around for this as well? :)
>>
>
> You could do what I've done for my own DOS, Windows,  and Linux
>  computers for years:
>
> disable the caps-lock key

My solution on Windows is to turn on Toggle Keys in the Accessibility
options. That beeps when the Caps Lock (or Num or Scroll) is pressed.
-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to begin

2014-02-13 Thread pete suchsland
On Thursday, February 13, 2014 6:18:26 AM UTC-7, weixixiao wrote:
> http://www.codecademy.com
> 
> 
> 
> I have learned the basic rules of Python in this website.
> 
> 
> 
> What should I do next?where to go?
> 
> 
> 
> I download the Pycharm the free version and I think I  dunno how to use it 
> except a "Hello world"

...well use it some more!  Try 
print("hello world"*10) and then 
print(9+9) 
make a variable ...
x =99
if x = 99:
print("hello world")
make a class  ...
class Hello:
def __init__(self, word):
self.word = word
def returnme(self)
return (self.word)

a = Hello("yo whazzup?")
b = Hello("Allo")
c = Hello("Guttentag")
make a list:
l = [ a , b , c]
make a for loop:
for i in l:
print(i.returnme())

read the Python tutorial, lots of ways to get your feet wet!  I have PyCharm, 
Eclipse (with PyDev), and Idle, (all free) and I like them all.  CodeAcademy is 
a good idea too if you want an online course to get your started.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Martijn Faassen: The Call of Python 2.8

2014-04-14 Thread Pete Forman
Mark Lawrence  writes:

> On 14/04/2014 14:51, Marko Rauhamaa wrote:
>> Chris Angelico :
>>
>>> If you're going to do that, why not just port your code to 3.x and
>>> be done with it? Who has the resources to put hours and hours of dev
>>> time into a 2.8?
>
> The people who haven't had enough time over the last eight years to
> plan their upgrade path to 3.x. Eight years comes from the date of the
> first message here https://mail.python.org/pipermail/python-3000/
> which was 21/03/2006, so feel free to come up with a different answer
> for the time span.

Would it help if we adopted a non-numeric name for this product to
support eXisting Python for those who were notified some years ago that
Python 2 would be superseded? How about Python XP?

I thought not ;-)

-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt5 and virtualenv problem

2013-08-02 Thread Pete Forman
"D. Xenakis"  writes:

> I tried to install SIP and PyQt5 using the pip install command but it
> didnt work on both cases (i was getting errors), so i finally
> installed them using the windows installers provided in
> riverbankcomputing website.
> My problem though here is that whenever i try to create a new
> virtualenv enviroment, those packages are not included and i cant
> import them. How can i add PyQt5 to my new virt enviroment? What is
> the logic behind this problem so i understand whats going on here?
>
> Thx in advance

I can't comment on PyQt5 but I can say how to use PyQt4 with virtualenv
on Windows.

The Riverbank installers do not work in a virtualenv. However PySide
wraps PyQt4 in a compatible installer. To use the installer it should be
invoked with easy_install rather than pip install. Having installed it,
pip uninstall works.

https://pypi.python.org/pypi/PySide


The Riverbank installer can install PyQt5 to your master copy of Python.
You can then use the --system-site-packages flag when creating a
virtualenv. The default behavior of virtualenv changed in 1.7
(2011-11-30) from including system packages to excluding them.

-- 
Pete Forman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Pete Forman
Steven D'Aprano  writes:

> I think this is a bug in Python's UTF-8 handling, but I'm not sure.
[snip]
> py> s = '\ud800\udc01'
> py> s.encode('utf-8')
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in 
> position 0: surrogates not allowed
>
>
> Have I misunderstood? I think that Python is being too strict about 
> rejecting surrogate code points. It should only reject lone surrogates, 
> or invalid pairs, not valid pairs. Have I misunderstood the Unicode FAQs, 
> or is this a bug in Python's handling of UTF-8?

http://www.unicode.org/versions/Unicode6.2.0/ch03.pdf

D75 Surrogate pair: A representation for a single abstract character
  that consists of a sequence of two 16-bit code units, where the first
  value of the pair is a high-surrogate code unit and the second value
  is a low-surrogate code unit.

* Surrogate pairs are used only in UTF-16. (See Section 3.9, Unicode
  EncodingForms.)

* Isolated surrogate code units have no interpretation on their own.
  Certain other isolated code units in other encoding forms also have no
  interpretation on their own. For example, the isolated byte [\x80] has
  no interpretation in UTF-8; it can be used only as part of a multibyte
  sequence. (See Table 3-7). It could be argued that this line by itself
  should raise an error.


That first bullet indicates that it is indeed illegal to use surrogate
pairs in UTF-8 or UTF-32.
-- 
Pete Forman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-26 Thread Pete Forman
Here's my Python sudoku solver which I wrote about 10 years ago.

http://petef.22web.org/sudoku/

It works by applying the solving techniques I came up with. No trial and
error or backtracking is used, so it is not up to cracking the very
hardest puzzles. Run time is 15 ms to 45 ms on a 2009 MacBook Pro using
Python 2.7.9.

There are verbose options to print the steps. Sizes and multiple grids
are flexible. IIRC it took a day or two to adapt the program when the
first samurai was published.

$ python sudoku.py -i sudoku2.sud
***|7**|***
1**|***|***
***|43*|2**
---+---+---
***|***|**6
***|5*9|***
***|***|418
---+---+---
***|*81|***
**2|***|*5*
*4*|***|3**
Solved, rating: dead easy
Calculation took 18.006 ms
264|715|839
137|892|645
598|436|271
---+---+---
423|178|596
816|549|723
759|623|418
---+---+---
375|281|964
982|364|157
641|957|382


-- 
Pete Forman
http://petef.22web.org/payg.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: file.write() of non-ASCII characters differs in Interpreted Python than in script run

2015-08-26 Thread Pete Dowdell

On 26/08/15 04:19, RAH wrote:

  UnicodeEncodeError: 'ascii' codec can't encode character '\\xc7' in position 
15: ordinal not in range(128)


(Hi all, this is my first post to the list)

This can be a frustrating issue to resolve, but your issue might be 
solved with this environment variable:

PYTHONIOENCODING=UTF-8

Regards, pd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem working with subprocess.check_call

2015-10-29 Thread Pete Dowdell

On 29/10/15 16:52, David Aldrich wrote:


Hi

I am working on Linux with Python 3.4.

I want to do a bash diff on two text files and show just the first 20 
lines of diff’s output.  So I tried:


>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')'

>>> subprocess.check_call(cmd, shell=True)



You could use a shell pipe in your command - and use str.format() too 
for better readability, perhaps:


> cmd = 'diff  {} {} | head -20'.format( file1, file2 )
> subprocess.check_call(cmd, shell=True)

Although this approach would not be recommended if file1 or file2 are 
not sanitised


pd
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting a string into a float that includes the negative

2015-11-08 Thread Pete Dowdell

On 08/11/15 09:11, phamton...@gmail.com wrote:

I am having issue with converting the string into a float because there is a negative, so 
only end up with "ValueError: invalid literal for float(): 81.4]"81.4]


The error is right there in the exception: you are trying to cast 
'81.4]' - that's a square bracket in the string.
You are also  removing the negative sign from your number before casting 
with your slice


this will fix it - change line:
long1 = long[1:]
to:
long1 = long[:-1]

test:
>>> TXT="[41.3, -81.4]\t6\t2011-08-28 19:02:28\tyay. little league 
world series!"

>>> float( TXT.split('\t')[0].split(', ')[1][:-1] )
-81.4

pd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-10 Thread Pete Dowdell

On 10/11/15 08:12, Bernie Lazlo wrote:

> > import json
> >import urllib
> >url ="http://www.wickson.net/geography_assignment.json";
> >response = urllib.urlopen(url)
> >data = json.loads(response.read())


All good up to data. Now:
# make a list of scores
scores = [d['score'] for d in data['comments']  if 
isinstance(d['score'], int) ]

# analysis
total_scores = sum(scores)
average_score= total_scores/float(len(scores))
min_score, max_score = min(scores), max(scores)

pd
--
https://mail.python.org/mailman/listinfo/python-list


Re: LBYL vs EAFP

2013-02-05 Thread Pete Forman
Steven D'Aprano  writes:
>> I want to check that a value is a number. [...]
> I'm leaning towards an isinstance check

Well that is the answer to your question, whether the value *is* a
number. EAFP can answer the question whether the value *behaves* like a
number, where the criterion depends on what your code is aiming to do
with the value.

BTW what if the value is Not-a-Number? ;-)

-- 
Pete Forman
-- 
http://mail.python.org/mailman/listinfo/python-list


zipfile and file permissions

2006-01-20 Thread Pete Forman
I'm trying to move the building of a zip file from a shell script into
python.  It is mostly working but when I unzip the files the UNIX
permissions are not preserved.  The zip program I've been using is the
standard(?) one on Linux, from Info-Zip.  Presumably I need to do
something with external_attr in ZipInfo, any pointers?
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   opinion of Schlumberger, Baker
http://petef.port5.com   -./\.-   Hughes or their divisions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to measure execution time of a program

2006-06-28 Thread Pete Forman
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
 > simplest way:
 >
 > t0 = time.time()

You can get better resolution by using time.clock() instead of
time.time().
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   opinion of Schlumberger, Baker
http://petef.port5.com   -./\.-   Hughes or their divisions.

Inviato da X-Privat.Org - Registrazione gratuita 
http://www.x-privat.org/join.php
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coding style and else statements

2006-08-31 Thread Pete Forman
Ben Finney <[EMAIL PROTECTED]> writes:

 > Why not ensure that there is one return point from the function, so
 > the reader doesn't have to remind themselves to look for hidden
 > return points?

There will always be more potential return points in languages that
support exceptions.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Windows upgrade incomplete

2006-12-21 Thread Pete Forman
I've a few versions of Python on my XP PC, most recently Python 2.5.
The file associations appear not to have been upgraded.  Executing a
.py file turned out to still be using 2.3.

>assoc .py
.py=Python.File

>ftype Python.file
Python.file=D:\PROGRA~1\Python23\python.exe "%1" %*

Presumably if I'd uninstalled the old Python first I'd have not seen
this.

I've amended my file type associations and all is now well.  Someone
might care to look at the installer.  I've used the MSIs since 2.4.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Internet Survey

2007-01-09 Thread Pete Fenelon
In comp.arch.embedded [EMAIL PROTECTED] wrote:
> Hello all,
> 
> I represent Octabox, an Internet Start-up developing a wide-scale

Hello. F*ck off, spammer.


pete
-- 
[EMAIL PROTECTED] "he just stuck to buying beer and pointing at other stuff"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: zipfile and file permissions

2006-01-23 Thread Pete Forman
Robert Kern <[EMAIL PROTECTED]> writes:

 > Pete Forman wrote:
>> I'm trying to move the building of a zip file from a shell script into
>> python.  It is mostly working but when I unzip the files the UNIX
>> permissions are not preserved.  The zip program I've been using is the
>> standard(?) one on Linux, from Info-Zip.  Presumably I need to do
>> something with external_attr in ZipInfo, any pointers?
>
 > C.f.: http://mail.python.org/pipermail/pythonmac-sig/2005-March/013491.html

Thanks.  I've put a work around in my code to set create_system.  I've
also made a patch for zipfile.py which I'm trying to submit to
sourceforge.  No luck so far, I'll try again later.  Recently I
submitted a patch to the python-mode project, so I think I'm following
the correct procedure.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   opinion of Schlumberger, Baker
http://petef.port5.com   -./\.-   Hughes or their divisions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Ovum quote about Python

2006-01-26 Thread Pete Forman
In an article about the Royal Bank of Scotland working with Zope there
is this quote from Gary Barnett, a research director at analyst firm
Ovum:

  "A lot of banks are using applications like Apache and Perl, but
  it's interesting to see they're using Python and Zope as it's
  moderately hardcore open source stuff".


http://news.zdnet.co.uk/software/applications/0,39020384,39248923,00.htm
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   opinion of Schlumberger, Baker
http://petef.port5.com   -./\.-   Hughes or their divisions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
André <[EMAIL PROTECTED]> writes:

 > Ok, doctest-based version of the Unit test example added; so much
 > more Pythonic ;-)

Sorry for being a bit picky but there are a number of things that I'm
unhappy with in that example.

1) It's the second example with 13 lines.  Though I suppose that the
   pragmatism of pairing the examples overriding an implicit goal of
   the page is itself Pythonic.

2) assert is not the simplest example of doctest.  The style should be

>>> add_money([0.13, 0.02])
0.15
>>> add_money([100.01, 99.99])
200.0
>>> add_money([0, -13.00, 13.00])
0.0

3) which fails :-(  So both the unittest and doctest examples ought to
   be redone to emphasize what they are doing without getting bogged
   down by issues of floating point representations.

http://wiki.python.org/moin/SimplePrograms

-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
Steve Howell <[EMAIL PROTECTED]> writes:

>> 2) assert is not the simplest example of doctest. 
>> The style should be
>> 
>> >>> add_money([0.13, 0.02])
>> 0.15
>> >>> add_money([100.01, 99.99])
>> 200.0
>> >>> add_money([0, -13.00, 13.00])
>> 0.0
>> 
>
 > That's not clear cut to me.  I think vertical
 > conciseness has an advantage for readability, as it
 > means you get to keep more "real" code on the screen.

What I meant was that doctest should be "type this into the
interpreter and you should see that".  A doctest is not a unit test,
though it may form a subset of the tests.  There should only be enough
doctests to enclue a human reader.  Comprehensive testing should use a
larger framework.  Doctests in separate files can do this but I would
use py.test, or alternatives like nose or Testoob.

>>> 2 + 2
4

"assert 2 + 2 == 4" is a concise way of writing a unit test but it is
not the best way to use doctest IMHO.

>> 3) which fails :-(  So both the unittest and doctest
>> examples ought to
>>be redone to emphasize what they are doing
>> without getting bogged
>>down by issues of floating point representations.
>> 
>
 > I was the one who originally posted the floating point
 > example (with yet another style of unit testing, BTW),
 > and I agree that the subtleties of floating point do
 > kind of cloud the issue.  I welcome a better example. 
 > What I didn't realize is that there's an actual error.
 >  Are you saying the program fails?  On which test?

Python 2.5.1 on XP:

Failed example:
add_money([0.13, 0.02])
Expected:
0.15
Got:
0.14999


-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
Steve Howell <[EMAIL PROTECTED]> writes:

 > Feel free to change the page as you see fit, although thanks for
 > discussing it here first.

Done.  I've moved classes up as unittest depends on it.

The changes that I made to classes were:

1) Use new style class.
2) Demonstrate Pythonic use of attribute (no get/set).
3) Pare some lines.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
Steve Howell <[EMAIL PROTECTED]> writes:

 >3) The median example raises the question of what
 > would happen with an empty list.  I don't think it's
 > important to cover that case in the simple example
 > (it's really the responsibility of the caller IMO not
 > to call median with nonsense arguments), but perhaps
 > there is a simple way to fix this?

An empty list raises an IndexError, a non-iterable raises TypeError.
This is correct behavior IMHO, there is nothing to fix.  Median should
return an element (or average of two) from its input and if that is
not meaningful returning None or other special value is neither
appropriate nor Pythonic.  Only the caller knows how to handle such
exceptional circumstances.

Actually there are some other issues.  Should the median of an even
number of integers allow halves?  Should median insist that its input
has an odd number of elements?  But it's tough squeezing all that
discourse into 13 or 14 lines ;-)  BankAccount allows arbitrarily
large withdrawals, is that to be fixed too?
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >