Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"?

Reply
Thread Tools

Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"?

 
 
Daniel Crespo
Guest
Posts: n/a
 
      11-11-2005
Is there a built-in method for transforming (1,None,"Hello!") to
1,None,"Hello!"?

Thanks

 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      11-11-2005
On 2005-11-11, Daniel Crespo <(E-Mail Removed)> wrote:
> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?


What transformation? The two are identical:

>>> x = (1,None,"Hello!")
>>> y = 1,None,"Hello!"
>>> x == y

True

--
Grant Edwards grante Yow! Nice decor!
at
visi.com
 
Reply With Quote
 
 
 
 
bonono@gmail.com
Guest
Posts: n/a
 
      11-11-2005
do you mean this ? otherwise, don't know what you want.

a, b, c = (1, None, "Hello!")

Daniel Crespo wrote:
> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?
>
> Thanks


 
Reply With Quote
 
Simon Brunning
Guest
Posts: n/a
 
      11-11-2005
On 11 Nov 2005 07:21:46 -0800, Daniel Crespo <(E-Mail Removed)> wrote:
> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?


There's no conversion to do:

>>> (1,None,"Hello!")

(1, None, 'Hello!')
>>> 1,None,"Hello!"

(1, None, 'Hello!')

They are both tuples contining identicle elements. What is it that you
want to do?

--
Cheers,
Simon B,
http://www.velocityreviews.com/forums/(E-Mail Removed),
http://www.brunningonline.net/simon/blog/
 
Reply With Quote
 
Alex Martelli
Guest
Posts: n/a
 
      11-11-2005
Daniel Crespo <(E-Mail Removed)> wrote:

> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?


You're mentioning two different literal syntaxes for the same object (a
tuple) -- the one with parentheses works everywhere, the other one
_almost_ everywhere (not where parentheses would be ambiguous).

Not sure, therefore, what you mean by "transforming" here; if you're
dealing with a string for in either case, for example, you could remove
the first and last characters by slicing with [1:-1], etc, etc. Perhaps
you can clarify exactly what you're asking for!


Alex
 
Reply With Quote
 
Amaury
Guest
Posts: n/a
 
      11-13-2005
Hello,

Daniel Crespo wrote:
> Is there a built-in method for transforming (1,None,"Hello!") to
> 1,None,"Hello!"?


As others answered before, the two syntaxes build the same object, so
there is no need to convert.

Except if you already have the tuple stored in a variable, and want to
call a function with the tree arguments:
args = (1,None,"Hello!")

func(args) # equivalent to func((1,None,"Hello!"))
func(*args) # equivalent to func(1,None,"Hello!")

Note the '*' on the second call, it will flatten the args, and 3
arguments are passed to the function.

--
Amaury
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.Net control for uploading, cropping and transforming graphics file FrankV ASP .Net 0 11-08-2005 03:28 AM
Transforming xml using xslt into a string variable? Ken Adams Java 1 03-10-2005 04:13 PM
Design Query - Transforming XML Roger Varley Java 0 02-03-2005 02:17 PM
Transforming XML with XSL to String Krista Lemieux ASP .Net 1 08-10-2004 02:41 PM
Transforming xml with server controls with xsl dwhitford ASP .Net 0 05-14-2004 02:44 PM



Advertisments