Re: [Tutor] Help with unnamed arguments in a merge function

2005-03-15 Thread Brian van den Broek
Colin Corr said unto the world upon 2005-03-16 01:38: Greetings Tutors, I am having some difficulties with the concept of functions which can accept an unnamed number of arguments. Specifically, when trying to write a function that deals with an unnamed number of dictionaries. I want to be able to

[Tutor] Help with unnamed arguments in a merge function

2005-03-15 Thread Colin Corr
Greetings Tutors, I am having some difficulties with the concept of functions which can accept an unnamed number of arguments. Specifically, when trying to write a function that deals with an unnamed number of dictionaries. I want to be able to merge any number of dictionaries, while preserving th

[Tutor] Re: Convert doesn't work... I'm stumped

2005-03-15 Thread Javier Ruere
Jacob S. wrote: Okay, not a very descriptive subject, but here goes... This is the code ### from decimal import Decimal as D Oh come on! """Everything is first converted to meters, and then converted to the unit you want to extend usage. dic[unit] = (unitto

Re: [Tutor] Convert doesn't work... I'm stumped

2005-03-15 Thread jfouhy
Quoting "Jacob S." <[EMAIL PROTECTED]>: > But, I digress--to the problem... > If I call convert(3,'ft','yd'), I should get Decimal("1") > instead, I get Decimal("1.195990046301080256481500617") At the risk of being blindingly obvious --- ft[0] is lambda x:381*x/1250 yd[1] is lambda x:1250/(1143*

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread Max Noel
On Mar 16, 2005, at 03:54, jrlen balane wrote: how would i make this the correct path: filename = "%s%s.txt" %('C:\Documents and Settings\nyer\My Documents\Info',time.strftime("%Y%m%d%H%M")) table_file = open(os.path.normpath(filename),"a") running on IDLE, i get the following error: Traceback (mos

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread jrlen balane
how would i make this the correct path: filename = "%s%s.txt" %('C:\Documents and Settings\nyer\My Documents\Info',time.strftime("%Y%m%d%H%M")) table_file = open(os.path.normpath(filename),"a") running on IDLE, i get the following error: Traceback (most recent call last): File "C:/Python23/prac

[Tutor] Convert doesn't work... I'm stumped

2005-03-15 Thread Jacob S.
Okay, not a very descriptive subject, but here goes... This is the code ### from decimal import Decimal as D """Everything is first converted to meters, and then converted to the unit you want to extend usage. dic[unit] = (unittometers,meterstounit) """ dic =

RE: [Tutor] new

2005-03-15 Thread Tony Meyer
> Do you want a container with a range in it, like the list > [1,2,3,4,5,...,100]: > > >>> range(100) > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, [...] > 92, 93, 94, 95, 96, 97, 98, 99] Opps. Notice that I did the range 0-99, of course. But it's still the function that you wan

RE: [Tutor] new

2005-03-15 Thread Tony Meyer
> Hey I am new at python and i am trying to learn about > it. I was wondering if you could tell me how to write > a range to 100. such as 1+2+3+4+5 ect. without > writing it out. Do you want a container with a range in it, like the list [1,2,3,4,5,...,100]: >>> range(100) [0, 1, 2, 3, 4, 5, 6

Re: [Tutor] new

2005-03-15 Thread Max Noel
On Mar 16, 2005, at 02:02, Ian Martin wrote: Hey I am new at python and i am trying to learn about it. I was wondering if you could tell me how to write a range to 100. such as 1+2+3+4+5 ect. without writing it out. Well, I'm not going to give you the full solution (that'd spoil the fun), but

[Tutor] new

2005-03-15 Thread Ian Martin
Hey I am new at python and i am trying to learn about it. I was wondering if you could tell me how to write a range to 100. such as 1+2+3+4+5 ect. without writing it out. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread Jacob S.
that is exactly what i am looking for, but how would i add this to my filename??? should i use this: output_file = open(os.path.join(self.Save_Session.GetValue(), time.strftime('%Y%m%d%H%M')), 'w') the self.Save_Session.GetValue() is generated by a dirdialog Uck,uck, uck, no... That's what Kent's

Re: [Tutor] strange hotshot error

2005-03-15 Thread Danny Yoo
On Tue, 15 Mar 2005 [EMAIL PROTECTED] wrote: > hi Danny, I had no idea Debian split its profiler into a separate > package in the testing distro. That would explain it, except I am using > Debian unstable with Debian stable for security packages, as my "more > /etc/apt/sources.list" output is:

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Liam Clarke
Sheesh. Star wars/programming humour. Better not be any Star Trek humour, that'll go over my head even further. On Tue, 15 Mar 2005 22:24:53 +, Max Noel <[EMAIL PROTECTED]> wrote: > > On Mar 15, 2005, at 21:59, Liam Clarke wrote: > > > On Tue, 15 Mar 2005 17:09:50 +, Max Noel <[EMAIL PR

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 21:59, Liam Clarke wrote: On Tue, 15 Mar 2005 17:09:50 +, Max Noel <[EMAIL PROTECTED]> wrote: re.findall returns a list object (as the error message says). Use name = x[1] instead. (and be careful, numbering starts from 0, so this code may contain a Kenobi error)

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Kent Johnson
Liam Clarke wrote: On Tue, 15 Mar 2005 17:09:50 +, Max Noel <[EMAIL PROTECTED]> wrote: re.findall returns a list object (as the error message says). Use name = x[1] instead. (and be careful, numbering starts from 0, so this code may contain a Kenobi error). Kenobi as in Obi Wan? or may

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Liam Clarke
On Tue, 15 Mar 2005 17:09:50 +, Max Noel <[EMAIL PROTECTED]> wrote: > > re.findall returns a list object (as the error message says). Use name > = x[1] instead. (and be careful, numbering starts from 0, so this code > may contain a Kenobi error). > Kenobi as in Obi Wan? -- 'Ther

Re: [Tutor] strange hotshot error

2005-03-15 Thread tpc
hi Danny, I had no idea Debian split its profiler into a separate package in the testing distro. That would explain it, except I am using Debian unstable with Debian stable for security packages, as my "more /etc/apt/sources.list" output is: nike:# more /etc/apt/sources.list #deb file:///cdrom/

Re: [Tutor] strange hotshot error

2005-03-15 Thread Danny Yoo
> This is highly unusual! This should have worked without any error > messages, as both the 'profile' and 'hotshot' modules are part of the > Standard Library, and should work out of the box. Hi Tpc, Oh, wait. The above statement is usually true, unless we're running something from a Linux dis

Re: [Tutor] strange hotshot error

2005-03-15 Thread Danny Yoo
On Tue, 15 Mar 2005 [EMAIL PROTECTED] wrote: > So I tried using the example code verbatim to see if I get the same > error messages, and I do! When I try "import hotshot.stats" I get: > > >>> import hotshot.stats > > Traceback (most recent call last): > File "", line 1, in -toplevel- > im

[Tutor] strange hotshot error

2005-03-15 Thread tpc
hi everyone, to anyone who has profiled their Python code using hotshot; I designed a test case using hotshot that is basically a stripped down version of the example code found here: http://www.python.org/doc/current/lib/hotshot-example.html So I tried using the example code verbatim to see if I

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 17:41, Ron Nixon wrote: Max: Thanks that seem to do the trick. One question though, how do you write a tuple out as a list to a new file like the example I have in my code Ron You mean, all the members of the list, separated by commas, with a new line at the end? Well, this ma

Re: [Tutor] How do you use pydoc?

2005-03-15 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-15 04:16: ok thanks for the help but i did what you said and heres what i got don't know exactly what i got but here lol will you help me figer what i got out and the module docs dose not work whem i go to the browser in opens a window sayi

Re: [Tutor] unicode type on cgi script

2005-03-15 Thread Lolo
Hi, Try this solution. Create a script named sitecustomize.py into your python lib directory (i.e /usr/lib/python2.3) and add the following code : #---sitecustomize.py--- import sys sys.setdefaultencoding('latin-1') See u, Lja --- BRINER Cedric <[EMAIL PROTECTED]> wrote: > python-2.3 apa

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Ron Nixon
Kent: The code is below. Here's the error message. Traceback (most recent call last): File "C:/Python24/reformat.py", line 5, in -toplevel- name = x.group(1) AttributeError: 'list' object has no attribute 'group' import re f = open('reformat.txt').read() pat = re.compile(r"([^\r\n]+)\n

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Max Noel
On Mar 15, 2005, at 16:44, Ron Nixon wrote: Kent: The code is below. Here's the error message. Traceback (most recent call last): File "C:/Python24/reformat.py", line 5, in -toplevel- name = x.group(1) AttributeError: 'list' object has no attribute 'group' re.findall returns a list object (a

Re: [Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Kent Johnson
Ron Nixon wrote: Thanks to all who replied to my post earlier on re's. I'm still preplexed by why re.search and re.match works in the code below, but not re.findall. re.findall is suppose to return all non-voerlapping occurances of the pattern that matches in this example, but it returns errors. L

[Tutor] re.findall vs. re.search and re.match

2005-03-15 Thread Ron Nixon
Thanks to all who replied to my post earlier on re's. I'm still preplexed by why re.search and re.match works in the code below, but not re.findall. re.findall is suppose to return all non-voerlapping occurances of the pattern that matches in this example, but it returns errors. Looking through th

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread jrlen balane
that is exactly what i am looking for, but how would i add this to my filename??? should i use this: output_file = open(os.path.join(self.Save_Session.GetValue(), time.strftime('%Y%m%d%H%M')), 'w') the self.Save_Session.GetValue() is generated by a dirdialog On Tue, 15 Mar 2005 09:41:35 -0600, C

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread C Smith
On Tuesday, Mar 15, 2005, at 05:01 America/Chicago, [EMAIL PROTECTED] wrote: how am i going to change the filename automaticaly? for example: #every 5 minutes, i am going to create a file based on the data above for i in range(100) output_file = file('c:/output' +.join(i) +'.txt

Re: [Tutor] unicode type on cgi script

2005-03-15 Thread Kent Johnson
BRINER Cedric wrote: print uses sys.stdout.encoding to encode unicode strings. You can check what this is in your cgi with import sys print sys.stdout.encoding didn't know I think it will work to explicitly encode the unicode string in the encoding you want for the web page. Try print content.enc

Re: [Tutor] FTP retrieve

2005-03-15 Thread Ewald Ertl
Hi! Looking up the ftplib-Module on my Solaris-Box >>> print sys.version 2.3.3 (#1, Mar 10 2004, 06:25:19) [GCC 3.3.2] I get the following doc for retrlines of the FTP-class: >>> print myFTP.retrlines.__doc__ Retrieve data in line mode. The argument is a RETR or LIST command.

Re: [Tutor] FTP retrieve

2005-03-15 Thread Kent Johnson
Øyvind wrote: I have opened an FTP connection, and use the following to download a logfile: f = open('c:///web.log','w') ftp.retrlines('RETR ex050202.log', f.write) I have also tried with f.writelines. It works, but not as well as I would like. All the \n's are removed. How can I download an exact

[Tutor] FTP retrieve

2005-03-15 Thread Øyvind
I have opened an FTP connection, and use the following to download a logfile: f = open('c:///web.log','w') ftp.retrlines('RETR ex050202.log', f.write) I have also tried with f.writelines. It works, but not as well as I would like. All the \n's are removed. How can I download an exact copy, so th

Re: [Tutor] Port 43 whois.ripe.net

2005-03-15 Thread Kent Johnson
Øyvind wrote: Hello. I need to query the whois at Ripe.net. It tells me to connect to port 43. I have found a description how to connect with .Net. http://www.aspheute.com/english/2825.asp I am not very familiar with network protocols, but assume this will be no big problem with Python. Can som

Re: [Tutor] unicode type on cgi script

2005-03-15 Thread Kent Johnson
BRINER Cedric wrote: python-2.3 apache2 hi, I'm trying to use unicode function into a cgi script with no success. # cedric.py--- #!/usr/bin/python import os,sys import cgi import cgitb; cgitb.enable() print "Content-Type: text/html\ "+os.linesep+"\ "+os.linesep+"hipo'potame" sys.stdout.flus

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread Kent Johnson
jrlen balane wrote: so for example, i have 5 arrays, i can do this (is this correct): data1[1,2,3,4,5 (and so on)] data2[1,2,3,4,5 (and so on)] data3[1,2,3,4,5 (and so on)] data4[1,2,3,4,5 (and so on)] data5[1,2,3,4,5 (and so on)] datas = [data1, data2, data3, data4, data5] for data in datas: l

Re: [Tutor] How do you use pydoc?

2005-03-15 Thread Kent Johnson
[EMAIL PROTECTED] wrote: * I have read but don't under stand how to use pydoc. here what i read can't figer out how to use it. One way to use pydoc is to start up a mini web server that delivers module documentation. On Windows, start the server with Start / Programs / Python / Module Docs.

Re: [Tutor] big numbers

2005-03-15 Thread Kent Johnson
Robert Storey wrote: This book is a few years old and was written for Python version 1.5, and of course I'm using version 2.3, so I'm just wondering if this whole issue of big numbers is now being handled automatically? Yes, it is. There have been many changes to Python since 1.5; when you are comf

[Tutor] Port 43 whois.ripe.net

2005-03-15 Thread Øyvind
Hello. I need to query the whois at Ripe.net. It tells me to connect to port 43. I have found a description how to connect with .Net. http://www.aspheute.com/english/2825.asp I am not very familiar with network protocols, but assume this will be no big problem with Python. Can someone point me

[Tutor] unicode type on cgi script

2005-03-15 Thread BRINER Cedric
python-2.3 apache2 hi, I'm trying to use unicode function into a cgi script with no success. # cedric.py--- #!/usr/bin/python import os,sys import cgi import cgitb; cgitb.enable() print "Content-Type: text/html\ "+os.linesep+"\ "+os.linesep+"hipo'potame" sys.stdout.flush() content = u'c\xe

Re: [Tutor] big numbers

2005-03-15 Thread Ewald Ertl
Hi! As far as I can remember, there was a change between some version's of python of 2.x. Now there is an automatic conversion from int to long, when it is necessary. Regards, Ewald on Tue, 15 Mar 2005 15:06:06 +0800 Robert Storey <[EMAIL PROTECTED]> wrote : --