Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Stefan Behnel
Jabin Jezreel wrote: > I am not allowed to do t = (1, *(2, 3)) > > But I am allowed to do def ts(*t): > ...return t > ... ts(1, *(2, 3)) > (1, 2, 3) > > I realize I can do (1,) + (2,3) > (1, 2, 3) > > What is the rationale behind not having t = (1, *(2, 3)) > have the sam

[Tutor] finding difference in time

2009-05-14 Thread R K
Gurus, I'm trying to write a fairly simple script that finds the number of hours / minutes / seconds between now and the next Friday at 1:30AM. I have a few little chunks of code but I can't seem to get everything to piece together nicely. import datetime,time now = datetime.datetime.now() i

Re: [Tutor] [Cheetahtemplate-discuss] cheetah is extremely hard to debug - error messages are non indicative TypeError: cannot concatenate 'str' and 'int' objects

2009-05-14 Thread R. Tyler Ballance
On Thu, May 14, 2009 at 12:20:42PM -0700, mobiledream...@gmail.com wrote: >How do i find which variable has error in these error messages? > >Nonetype object is unsubscriptable > >else:return web.render('searchesnew.html') > File "/home/mark/work/common/web/cheetah.py", line 103

Re: [Tutor] cheetah is extremely hard to debug - error messages are non indicative TypeError: cannot concatenate 'str' and 'int' objects

2009-05-14 Thread mobiledreamers
Cheetah is usually not run from ipython! On Thu, May 14, 2009 at 12:40 PM, Kent Johnson wrote: > On Thu, May 14, 2009 at 3:20 PM, wrote: > > How do i find which variable has error in these error messages? > > Generally by looking at the last source line in the traceback you can > figure it out

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread Sander Sweers
Forwarding to list because of mail delivery error... 2009/5/15 Sander Sweers : > 2009/5/14 MK : >> i am using this code to send an "cat > ThisIsMyUrl" with popen. > > First, I am not sure if you understand what "cat > ThisIsMyUrl" > actually does... It waits for data on *stdin* and pipes it to > T

Re: [Tutor] Python popen command using cat > textfile .... how toterminate

2009-05-14 Thread Alan Gauld
"vince spicer" wrote Take a peak at commands.getoutput Or more "correctly" look at the subprocess module. All previous mechanisms for process control are rendered obsolete and are deprecated in favour of subprocess So if we aren't using popen lets at least use subprocess. It is slightly mo

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread Martin Walsh
MK wrote: > Hi there, > > i am using this code to send an "cat > ThisIsMyUrl" with popen. > Of cos cat now waits for the CTRL+D command. > How can i send this command ? > > def console_command(cmd): > print cmd > console = os.popen(cmd,"r") > output = console.read() > con

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread vince spicer
import commands On Thu, May 14, 2009 at 4:28 PM, vince spicer wrote: > Take a peak at commands.getoutput > > > EX: > > import commmands > > ls = commands.getoutput("ls- ls") > > Vince > > > On Thu, May 14, 2009 at 3:50 PM, MK wrote: > >> Hi there, >> >> i am using this code to send an "cat > Th

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread vince spicer
Take a peak at commands.getoutput EX: import commmands ls = commands.getoutput("ls- ls") Vince On Thu, May 14, 2009 at 3:50 PM, MK wrote: > Hi there, > > i am using this code to send an "cat > ThisIsMyUrl" with popen. > Of cos cat now waits for the CTRL+D command. > How can i send this comm

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Larry Riedel
> > >>> x = (2, 3) > > >>> y = (1, *x) > > File "", line 1 > > SyntaxError: can use starred expression only as assignment target > > But you can already do that without needing to extend * notation > to work like that To me the "*" notation already /appears/ to work like that: (Python 3.x) >>

[Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread MK
Hi there, i am using this code to send an "cat > ThisIsMyUrl" with popen. Of cos cat now waits for the CTRL+D command. How can i send this command ? def console_command(cmd): print cmd console = os.popen(cmd,"r") output = console.read() console.close() ret

Re: [Tutor] cheetah is extremely hard to debug -error messages are non indicative TypeError: cannotconcatenate 'str' and 'int' objects

2009-05-14 Thread Alan Gauld
wrote How do i find which variable has error in these error messages? *Nonetype object is unsubscriptable* You need to send the entire error message, the last line is not much good without the context. But you should see a line in the traceback where a subscript aka indexing) operation is

Re: [Tutor] Sorting a list

2009-05-14 Thread Walker Hale IV
The prize goes to Bob Gailer! This solution is not only shortest, but works perfectly with negative numbers. -- Walker Hale On Thu, May 14, 2009 at 1:22 PM, bob gailer wrote: > Lie Ryan wrote: >> >> Timo wrote: >>> >>> Hello, >>> >>> I don't think this should be difficult, so maybe I look over

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Steve Willoughby
On Thu, May 14, 2009 at 11:10:53AM -0700, Jabin Jezreel wrote: > > Why not just write is simply as (1, 2, 3) instead of > > the confusing (1, *(2, 3))? > > It is a contrived example. In practice it would be > something more like: > > >>> def ts(*t): > ... return t > ... > >>> x = (2, 3) > >>

Re: [Tutor] cheetah is extremely hard to debug - error messages are non indicative TypeError: cannot concatenate 'str' and 'int' objects

2009-05-14 Thread Kent Johnson
On Thu, May 14, 2009 at 3:20 PM, wrote: > How do i find which variable has error in these error messages? Generally by looking at the last source line in the traceback you can figure it out. IPython has an extended traceback mode that shows variables (see the xmode magic command) http://ipython

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Jabin Jezreel
> Why not just write is simply as (1, 2, 3) instead of > the confusing (1, *(2, 3))? It is a contrived example. In practice it would be something more like: >>> def ts(*t): ... return t ... >>> x = (2, 3) >>> y = (1, *x) File "", line 1 SyntaxError: can use starred expression only as assig

[Tutor] cheetah is extremely hard to debug - error messages are non indicative TypeError: cannot concatenate 'str' and 'int' objects

2009-05-14 Thread mobiledreamers
How do i find which variable has error in these error messages? *Nonetype object is unsubscriptable* else:return web.render('searchesnew.html') File "/home/mark/work/common/web/cheetah.py", line 103, in render return str(compiled_tmpl) File "/usr/lib/python2.5/site-packages/Cheetah-2.0.1

Re: [Tutor] Sorting a list

2009-05-14 Thread bob gailer
Lie Ryan wrote: Timo wrote: Hello, I don't think this should be difficult, so maybe I look over it. But I can't seem to find the solution. I have a list with one word and a couple of numbers. Now I want the word to be kept in the first location and the numbers to be sorted. So this: [4, 6

Re: [Tutor] Sorting a list

2009-05-14 Thread bob gailer
Christian Witts wrote: Kent Johnson wrote: On Thu, May 14, 2009 at 3:34 AM, Timo wrote: Emile van Sebille schreef: If this is always the case you can use the sort method of lists, then relocate the last entry to the front -- a = [4, 6, 'word', 3, 9] a.sort() a.insert(0,a

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Lie Ryan
Steve Willoughby wrote: Lie Ryan wrote: Jabin Jezreel wrote: I am not allowed to do t = (1, *(2, 3)) But I am allowed to do def ts(*t): return t ts(1, *(2, 3)) (1, 2, 3) I realize I can do (1,) + (2,3) (1, 2, 3) What is the rationale behind not having t = (1, *(2, 3)) hav

[Tutor] How to handle complexType returned by wsdl using SOAPpy

2009-05-14 Thread vishwajeet singh
Hi, soapUrl = constants.JIRA_PATH + '/jira/rpc/soap/jirasoapservice-v2?wsdl' soap = SOAPpy.WSDL.Proxy(soapUrl) auth = soap.login(constants.JIRA_USERNAME,constants.JIRA_PASSWORD) b = Types.longType(10041L) role = soap.getProjectRole(auth,b) project = soap.getProjectByKey(auth,'TEMP') Now I want

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Steve Willoughby
Lie Ryan wrote: > Jabin Jezreel wrote: >> I am not allowed to do > t = (1, *(2, 3)) >> >> But I am allowed to do > def ts(*t): >> return t >> > ts(1, *(2, 3)) >> (1, 2, 3) >> >> I realize I can do > (1,) + (2,3) >> (1, 2, 3) >> >> What is the rationale behind not having

Re: [Tutor] Sorting a list

2009-05-14 Thread Kent Johnson
On Thu, May 14, 2009 at 9:13 AM, Lie Ryan wrote: > Why not: sorted(lst, key=lambda x: (0, x) if isinstance(x, str) else (1, x)) > ['word', 3, 4, 6, 9] > > I think sorting tuple has a well-defined meaning, i.e. sort on first item, > then second, then third, etc... and there is AFAIK no restric

Re: [Tutor] Sorting a list

2009-05-14 Thread Kent Johnson
On Wed, May 13, 2009 at 1:25 PM, Alan Gauld wrote: > def compare(x,y): >    if type(x) == str:  return  -1 >    if type(y) == str: return 1 >    return cmp(x,y) > > > Runs into problems if you have multiple strings and want them sorted too... A slight variation - if the types are the same, use c

Re: [Tutor] Sorting a list

2009-05-14 Thread Lie Ryan
Timo wrote: Hello, I don't think this should be difficult, so maybe I look over it. But I can't seem to find the solution. I have a list with one word and a couple of numbers. Now I want the word to be kept in the first location and the numbers to be sorted. So this: [4, 6, 'word', 3, 9]

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Lie Ryan
Jabin Jezreel wrote: I am not allowed to do t = (1, *(2, 3)) But I am allowed to do def ts(*t): return t ts(1, *(2, 3)) (1, 2, 3) I realize I can do (1,) + (2,3) (1, 2, 3) What is the rationale behind not having t = (1, *(2, 3)) have the same semantics as the "ts" case abo

Re: [Tutor] Sorting a list

2009-05-14 Thread spir
Le Thu, 14 May 2009 12:24:15 +0200, Christian Witts s'exprima ainsi: > The ability to compare unlike objects at all is considered a > mis-feature and has been removed in Python 3: > http://mail.python.org/pipermail/python-dev/2004-June/045111.html Great! Thanks for the informaton, Kent. Denis -

Re: [Tutor] t = (1, *(2, 3))

2009-05-14 Thread Alan Gauld
"Jabin Jezreel" wrote I am not allowed to do >>> t = (1, *(2, 3)) Just to be clear, what do you think this means? What would you expect to happen? But I am allowed to do >>> def ts(*t): ... return t ... >>> ts(1, *(2, 3)) (1, 2, 3) What do you think is happening here that is different?

Re: [Tutor] Sorting a list

2009-05-14 Thread Christian Witts
Kent Johnson wrote: On Thu, May 14, 2009 at 3:34 AM, Timo wrote: Emile van Sebille schreef: If this is always the case you can use the sort method of lists, then relocate the last entry to the front -- a = [4, 6, 'word', 3, 9] a.sort() a.insert(0,a.pop()) a

Re: [Tutor] Sorting a list

2009-05-14 Thread Kent Johnson
On Thu, May 14, 2009 at 3:34 AM, Timo wrote: > Emile van Sebille schreef: >> If this is always the case you can use the sort method of lists, then >> relocate the last entry to the front -- >> >> >>> a = [4, 6, 'word', 3, 9] >> >>> a.sort() >> >>> a.insert(0,a.pop()) >> >>> a >> ['word', 3, 4, 6,

[Tutor] t = (1, *(2, 3))

2009-05-14 Thread Jabin Jezreel
I am not allowed to do >>> t = (1, *(2, 3)) But I am allowed to do >>> def ts(*t): ...    return t ... >>> ts(1, *(2, 3)) (1, 2, 3) I realize I can do >>> (1,) + (2,3) (1, 2, 3) What is the rationale behind not having t = (1, *(2, 3)) have the same semantics as the "ts" case above? _

Re: [Tutor] Sorting a list

2009-05-14 Thread Timo
Emile van Sebille schreef: On 5/13/2009 9:25 AM Timo said... Hello, I don't think this should be difficult, so maybe I look over it. But I can't seem to find the solution. I have a list with one word and a couple of numbers. If this is always the case you can use the sort method of lists,