Re: type conversion

2009-01-10 Thread Lie
On Jan 3, 10:23 am, r rt8...@gmail.com wrote: On Jan 2, 7:46 pm, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: ...incessant rambling about a news reader , 101 excuses for butting into a thread [snip] ... public display of ignorance of newsgroup ethics, 101 excuses for not

Re: type conversion

2009-01-02 Thread Robert Kern
r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16

Re: type conversion

2009-01-02 Thread r
On Jan 2, 1:46 pm, Robert Kern robert.k...@gmail.com wrote: r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to

RE: type conversion

2009-01-02 Thread Hamish McKenzie
12:12 PM To: python-list@python.org Subject: Re: type conversion On Jan 2, 1:46 pm, Robert Kern robert.k...@gmail.com wrote: r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety

Re: type conversion

2009-01-02 Thread Christian Heimes
Hamish McKenzie schrieb: I actually have no idea what ur talking about... aren't conversations threaded by subject? Nope, they are threaded by message id. The subject is used as fallback only. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: type conversion

2009-01-02 Thread Steven D'Aprano
On Fri, 02 Jan 2009 15:49:25 -0800, Hamish McKenzie wrote: I actually have no idea what ur talking about... aren't conversations threaded by subject? Not usually. When you hit Reply to a post, your post gets a hidden header line that says I'm a reply to post #12345 (whatever post number it

Re: type conversion

2009-01-02 Thread r
On Jan 2, 7:46 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: ...incessant rambling about a news reader , 101 excuses for butting into a thread [snip] Throw your newsreader in the garbage and use Google groups, less headache, more filling! No need to worry about hidden headers

Re: type conversion

2009-01-01 Thread Robert Kern
Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix or a quaternion. is there any other way to do it

RE: type conversion

2009-01-01 Thread Hamish McKenzie
You could also use a dict with type:method key/value pairings. This is closer to a switch/case than an if...elif chain is. of course, that's a great idea... thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: type conversion

2009-01-01 Thread r
On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16

Re: type conversion

2008-12-31 Thread Steven D'Aprano
On Wed, 31 Dec 2008 12:35:20 -0800, Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. Type conversion is a bit of a misleading subject line. You're not really converting different types, just initialising from different types.

Re: type conversion

2008-12-31 Thread Benjamin Kaplan
On Wed, Dec 31, 2008 at 5:26 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Wed, 31 Dec 2008 12:35:20 -0800, Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. Type conversion is a bit of a misleading

Re: Type conversion?

2006-08-18 Thread Rob Cowie
KraftDiner wrote: I have the following code... import array len32 = array.array('L') len16 = array.array('H') len32.append(0) len16.append(0) y = len32[0] print y.__class__ type 'long' z = len16[0] print z.__class__ type 'int' how can I change Zs type to long? z_long = long(z)

Re: Type conversion?

2006-08-18 Thread KraftDiner
Rob Cowie wrote: KraftDiner wrote: I have the following code... import array len32 = array.array('L') len16 = array.array('H') len32.append(0) len16.append(0) y = len32[0] print y.__class__ type 'long' z = len16[0] print z.__class__ type 'int' how can I change

Re: Type conversion?

2006-08-18 Thread Duncan Booth
KraftDiner wrote: In C++ you can cast one class type to another if you override the operator= Then you can convert one class type to another... In Python it would appear that the left hand side of the assignment operator is not used to determine if a cast is necessary. So how would I do

Re: Type conversion?

2006-08-18 Thread Paul McGuire
KraftDiner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In C++ you can cast one class type to another if you override the operator= Then you can convert one class type to another... In Python it would appear that the left hand side of the assignment operator is not used to