typed variables (WAS re.compile.match() results ...)

Steven Bethard steven.bethard at gmail.com
Thu Nov 11 14:28:42 EST 2004


Stefan Seefeld <seefeld <at> sympatico.ca> writes:

> 
> Steven Bethard wrote:
> 
> > I think perhaps Axel Bock was getting a little pedantic here.

Sorry, I misread the quoting.  s/Axel Bock/Scott David Daniels.  Sorry!

> > Python does not have typed variables; any "variable" in Python can hold an
> > object of any type.  Hence examples like:
> 
> I don't see this as a contradiction (but then, may be we'd need to 
> define what 'variable' means, the reference or the referee). I only
> meant to point out that there is a distinction between strong/weak
> and static/dynamic typing, and thus, that Axel's question was perfectly
> valid.

Yeah, that's why I said the responder was being pedantic.  The question is, of
course, a valid one.

I think the phrasing could have been a little confusing though -- if you thought
that the OP believed that "variables" in Python could be of type str (meaning
that they were statically typed), then you would interpret his question as "how
does a str-typed variable get converted into a unicode-typed variable?" instead
of the real question, "why does m.groups() return unicode objects?"

Again, the question was valid -- I just thought it would be helpful to explain
what Scott David Daniels meant when he said "Python does not have typed
variables", and perhaps give a more standard wording for these kind of
descriptions in Python.

Steve




More information about the Python-list mailing list