[Tutor] [Fwd: Re: Command line args]

2007-04-09 Thread Luke Paireepinart
Sorry, guys. Accidentally replied off-list. --- Begin Message --- Kirk Bailey wrote: ok, try this: Try: You're still using an uppercase try. Python is case sensitive. Unless you're doing some voodoo magic to make Try be an alias for try, this won't work. filename=sys.arv[1] exc

Re: [Tutor] Command line args

2007-04-09 Thread Kirk Bailey
ok, try this: Try: filename=sys.arv[1] except Exception, e: if filename='': filename='foo' # define a default value else: if foo: # detect one likely error foobarcode else:

Re: [Tutor] vim confusion (was copy2 arguments?)

2007-04-09 Thread Robert H. Haener IV
Alan, What you mistook for "vim 8" (with some garbage afterward) was in fact a smiley I use frequently. -Robert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] copy2 arguments?

2007-04-09 Thread Alan Gauld
"Robert H. Haener IV" <[EMAIL PROTECTED]> wrote >, I may have to stop coding Python in vim 8?} vim 8?!! I didn't hardly notice that vim 7 was out! Time for an upgrade I guess... Alan G ___ Tutor maillist - Tutor@python.org http://mail.python

Re: [Tutor] Command line args

2007-04-09 Thread Luke Paireepinart
Kirk Bailey wrote: > Teresa Stanton wrote: > >> If one argument to a script is provided I am to take the input from it. >> I figure that is presented like this: >> >> filename = sys.argv[1] >> > Try: > the 'try' keyword is not capitalized in Python. > filename=sys.arg[1] > except

Re: [Tutor] how to split a stream of chars

2007-04-09 Thread Bob Gailer
<[EMAIL PROTECTED]> wrote >> i have a long stream of data, represented in hexadecimal >> form. I need to split it in bytes (by 2 chars each). eg >> '00010203040506'... -> ['00', '01, '02' ...]. >> >> So my question is: is there an inverse function of zip, or >> an easy way to split this long s

Re: [Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Kent Johnson
Alan Gauld wrote: > "Dick Moores" <[EMAIL PROTECTED]> wrote > >> lstNums = [] >> for x in lstSvg: >> num = int(x.split('.')[0]) >> lstNums.append(num) > > This is exactly what a list comp does so you could rewrite it as: > > lstNums = [int(x.split('.')[0]) for x in lstSv

Re: [Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Dick Moores
At 08:19 AM 4/9/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > lstNums = [] > > for x in lstSvg: > > num = int(x.split('.')[0]) > > lstNums.append(num) > >This is exactly what a list comp does so you could rewrite it as: > >lstNums = [int(x.split('.')

Re: [Tutor] copy2 arguments?

2007-04-09 Thread Robert H. Haener IV
Never mind, SPE answered my question for me. Heh, I may have to stop coding Python in vim 8?} -Robert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] copy2 arguments?

2007-04-09 Thread Robert H. Haener IV
Hey folks, I just need to know if shutil.copy2() will accept a directory as the destination or if I have to supply a full path including the name of the file (e.g. "C:\foo\bar.txt" as opposed to "C:\foo\"). The target is 32-bit Windows XP with Python 2.5. -Robert _

Re: [Tutor] how to split a stream of chars

2007-04-09 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > i have a long stream of data, represented in hexadecimal > form. I need to split it in bytes (by 2 chars each). eg > '00010203040506'... -> ['00', '01, '02' ...]. > So my question is: is there an inverse function of zip, or > an easy way to split this long string in p

Re: [Tutor] Addressing a variable whose name is the value of a string

2007-04-09 Thread Andreas Pfrengle
Kent Johnson wrote: > Andreas Pfrengle wrote: > >> # Accessing db (see http://www.djangoproject.com/documentation/db-api/): >> myobj = MyModel.objects.get() >> var = myobj.vector >> # vector is a Textfield, so var now contains a string, naming another >> db-field of myobj >> >> execstr = "attr =

Re: [Tutor] Addressing a variable whose name is the value of a string

2007-04-09 Thread Kent Johnson
Andreas Pfrengle wrote: > # Accessing db (see http://www.djangoproject.com/documentation/db-api/): > myobj = MyModel.objects.get() > var = myobj.vector > # vector is a Textfield, so var now contains a string, naming another > db-field of myobj > > execstr = "attr = myobj." + var > exec execstr >

[Tutor] how to split a stream of chars

2007-04-09 Thread emilia12
hi list, i have a long stream of data, represented in hexadecimal form. I need to split it in bytes (by 2 chars each). eg '00010203040506'... -> ['00', '01, '02' ...]. So my question is: is there an inverse function of zip, or an easy way to split this long string in pairs (without indexing in cyc

Re: [Tutor] Addressing a variable whose name is the value of a string

2007-04-09 Thread Andreas Pfrengle
Bob Gailer wrote: > Andreas Pfrengle wrote: > >> [snip] > >> looks good if I'm happy with my values inside mydict and don't want >> to have sth. like x=5 in the end. But since 'x' is the name of a >> database field (I simplified it here for an example), I still see no >> way around the exec, so

Re: [Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > lstNums = [] > for x in lstSvg: > num = int(x.split('.')[0]) > lstNums.append(num) This is exactly what a list comp does so you could rewrite it as: lstNums = [int(x.split('.')[0]) for x in lstSvg] One of the cases where I actua

Re: [Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Dick Moores
At 03:39 AM 4/9/2007, Kent Johnson wrote: >Dick Moores wrote: >>Sorry if my Subject line isn't clear about what my question is. >>I have a script that uses the turtle and random modules to create >>SVG files, one after another, in a directory just for the SVGs. The >>script assigns filenames in t

Re: [Tutor] reassign

2007-04-09 Thread Rikard Bosnjakovic
On 4/8/07, linda.s <[EMAIL PROTECTED]> wrote: > how i can randomly reassign the values to different location in the list? >>> import random >>> mylist = [1,2,3,4,5,6,7,8,9] >>> mylist [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> random.shuffle(mylist) >>> mylist [3, 6, 9, 4, 7, 1, 2, 8, 5] -- - Rikard - ht

Re: [Tutor] Movies from jpg files

2007-04-09 Thread Rikard Bosnjakovic
On 4/7/07, János Juhász <[EMAIL PROTECTED]> wrote: May you recommend anything to build them easy ? I use this C-shell script for the same purpose. Even if it doesn't add up to the features you want, you can always use it as reference for re-hacking. -- - Rikard - http://bos.hack.org/cv/ ma

Re: [Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Kent Johnson
Dick Moores wrote: > Sorry if my Subject line isn't clear about what my question is. > > I have a script that uses the turtle and random modules to create SVG > files, one after another, in a directory just for the SVGs. The > script assigns filenames in the form, "n.svg", where n is an integer.

Re: [Tutor] Addressing a variable whose name is the value of a string

2007-04-09 Thread Jordan Greenberg
Andreas Pfrengle wrote: > Bob Gailer wrote: > >> Andreas Pfrengle wrote: >> >>> Hello, >>> >>> I want to change the value of a variable whose name I don't know, but >>> this name is stored as a string in another variable, like: >>> >>> x = 1 >>> var = 'x' >>> >>> Now I want to change the value of

[Tutor] Creating new files w/o overwriting existing ones

2007-04-09 Thread Dick Moores
Sorry if my Subject line isn't clear about what my question is. I have a script that uses the turtle and random modules to create SVG files, one after another, in a directory just for the SVGs. The script assigns filenames in the form, "n.svg", where n is an integer. E.g. 1.svg, 2.svg. 3.svg, .