python beginner problem(?)

S

Steve Holden

Alan said:
Win2k Pro - installed python: ok

Example 2.1 from DiveIntoPython tutorial copied
and pasted into "Pythonwin - Python IDE and GUI
Framework for Windows."
--------------------------------------------------------------
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.

Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])

if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret" \
}
print buildConnectionString(myParams)
--------------------------------------------------------------

produces..

=================================================23: DeprecationWarning: raising a string exception is deprecated
raise win32ui.error, "The MFC object has died."
pwd=secret;database=master;uid=sa;server=mpilgrim
=================================================

DiveIntoPython example 2.1 result:
server=mpilgrim;uid=sa;database=master;pwd=secret

..which I realise is essentially the same (except for order).

I haven't ever (not that I remember) installed MFC.

Help!
MFC is the Microsoft Foundation Classes, used by many Windows
programmers to create applications. Mark Hammond, the author of
PythonWin, used them to build that.

I am hugely surprised to find that PythonWin apparently raises string
exceptions: this is an old programming technique, which should have been
removed from anything designed to run on Python 2.5. That is why you see
the message: it's only a warning, so you can ignore it. I am copying
Mark on this message in case he's unaware of the issue.

Don't be surprised if the ordering of the elements in a dict is
different between Python versions - a dict is an unordered collection,
and so the ordering of the elements isn't supposed to be predictable.
Mark Pilgrim probably used an earlier version of Python to prepare the
examples, that text has been around some time (though it's still good).

regards
Steve
 
A

Alan Illeman

Win2k Pro - installed python: ok

Example 2.1 from DiveIntoPython tutorial copied
and pasted into "Pythonwin - Python IDE and GUI
Framework for Windows."
--------------------------------------------------------------
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.

Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])

if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret" \
}
print buildConnectionString(myParams)
--------------------------------------------------------------

produces..

=================================================23: DeprecationWarning: raising a string exception is deprecated
raise win32ui.error, "The MFC object has died."
pwd=secret;database=master;uid=sa;server=mpilgrim
=================================================

DiveIntoPython example 2.1 result:
server=mpilgrim;uid=sa;database=master;pwd=secret

...which I realise is essentially the same (except for order).

I haven't ever (not that I remember) installed MFC.

Help!

tia
Alan
 
S

Steve Holden

Steve said:
Alan said:
Win2k Pro - installed python: ok
[...]
=================================================
C:\Python25\Lib\site-packages\pythonwin\pywin\mfc\object.py:
23: DeprecationWarning: raising a string exception is deprecated
raise win32ui.error, "The MFC object has died."
pwd=secret;database=master;uid=sa;server=mpilgrim
=================================================

DiveIntoPython example 2.1 result:
server=mpilgrim;uid=sa;database=master;pwd=secret

..which I realise is essentially the same (except for order).

I haven't ever (not that I remember) installed MFC.

Help!
[...]
I am hugely surprised to find that PythonWin apparently raises string
exceptions: this is an old programming technique, which should have been
removed from anything designed to run on Python 2.5. That is why you see
the message: it's only a warning, so you can ignore it. I am copying
Mark on this message in case he's unaware of the issue.
[...]

In a private reply Mark Hammond says he will fix this in the next
release - thanks for the report!

regards
Steve
 
S

Steve Holden

Alan said:
Steve Holden said:
Steve said:
Alan Illeman wrote:
Win2k Pro - installed python: ok
[...]
=================================================
C:\Python25\Lib\site-packages\pythonwin\pywin\mfc\object.py:
23: DeprecationWarning: raising a string exception is deprecated
raise win32ui.error, "The MFC object has died."
pwd=secret;database=master;uid=sa;server=mpilgrim
=================================================

DiveIntoPython example 2.1 result:
server=mpilgrim;uid=sa;database=master;pwd=secret

..which I realise is essentially the same (except for order).

I haven't ever (not that I remember) installed MFC.

Help!
[...]
I am hugely surprised to find that PythonWin apparently raises string
exceptions: this is an old programming technique, which should have been
removed from anything designed to run on Python 2.5. That is why you see
the message: it's only a warning, so you can ignore it. I am copying
Mark on this message in case he's unaware of the issue.
[...]

In a private reply Mark Hammond says he will fix this in the next
release - thanks for the report!

regards
Steve

Thanks Steve for both your replies.
Was (or is) python a piggyback for MFC?
You are supposed to be able to access the MFC classes through PythonWin,
but I have never personally bothered because MFC is too horrible to
tangle with.

regards
Steve
 
A

Alan Illeman

Steve Holden said:
Steve said:
Alan said:
Win2k Pro - installed python: ok
[...]
=================================================
C:\Python25\Lib\site-packages\pythonwin\pywin\mfc\object.py:
23: DeprecationWarning: raising a string exception is deprecated
raise win32ui.error, "The MFC object has died."
pwd=secret;database=master;uid=sa;server=mpilgrim
=================================================

DiveIntoPython example 2.1 result:
server=mpilgrim;uid=sa;database=master;pwd=secret

..which I realise is essentially the same (except for order).

I haven't ever (not that I remember) installed MFC.

Help!
[...]
I am hugely surprised to find that PythonWin apparently raises string
exceptions: this is an old programming technique, which should have been
removed from anything designed to run on Python 2.5. That is why you see
the message: it's only a warning, so you can ignore it. I am copying
Mark on this message in case he's unaware of the issue.
[...]

In a private reply Mark Hammond says he will fix this in the next
release - thanks for the report!

regards
Steve

Thanks Steve for both your replies.
Was (or is) python a piggyback for MFC?
 
A

Alan Illeman

Steve Holden said:
You are supposed to be able to access the MFC classes through PythonWin,
but I have never personally bothered because MFC is too horrible to
tangle with.

regards
Steve

That's a relief; I always hated MFC. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top