Re: Crashes always on Windows 7

2012-08-17 Thread Terry Reedy

On 8/17/2012 11:09 PM, zmagi...@gmail.com wrote:


Hi Hi, sorry for the confusion. Yes, I meant ActiveState
ActivePython. It worked fine for a few hours and now every time I
open up the IDLE Shell, it opens fine. Then when I try to open a
previously made file, the shell immediately closes and nothing else
happens.



When I enter Python in the command line, I get the
ActivePython information.


Being specific is really important. The subject line is slightly 
misleading. Python is working fine for you. Idle is too. I *suspect* you 
are trying to open via a Library or Favorite. There is a known issue 
that this does not work on Win 7 and it seems to be a bug in tcl/tk or 
Windows that we have no control or responsibility for. Opening via a 
normal directory works fine. If the above is *not* what you are doing, 
please be exactly specific.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Crashes always on Windows 7

2012-08-17 Thread zmagic11
On Friday, August 17, 2012 9:38:16 PM UTC+8, zmag...@gmail.com wrote:
> Hi,
> 
> 
> 
> Downloaded ActiveSync ActivePython on my Windows 7 machine. Worked for a 
> little while and now it crashes every time I try to boot the IDLE or open a 
> program, it crashes. Help please? Thanks

Open using File>Open on the Shell
-- 
http://mail.python.org/mailman/listinfo/python-list


python-list@python.org

2012-08-17 Thread Ben Finney
Grant Edwards  writes:

> On 2012-08-16, Chris Angelico  wrote:
> > And FWIW, I add my voice to those who prefer to read replies
> > underneath the original text.
>
> Same here.  I often skip reading top-posted articles entirely, since I
> don't really care to take the time to start reading at the bottom,
> working my up, trying to figure out exactly what the poster is
> replying or referring to in the blob of context-free text at the top.

+1. A message which is top-posted is a fairly reliable indicator that
the message wasn't written with much consideration for the reader, so I
tend to just skip those messages.

If you don't care whether your messages are read, continue to top-post.

If you want to show that you've made efforts to make your message more
readable, use interleaved replies and trim off material to which you're
not replying http://brooksreview.net/2011/01/interleaved-email/>.

-- 
 \  “We tend to scoff at the beliefs of the ancients. But we can't |
  `\scoff at them personally, to their faces, and this is what |
_o__) annoys me.” —Jack Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex Question

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 2:41 PM, Frank Koshti  wrote:
> Hi,
>
> I'm new to regular expressions. I want to be able to match for tokens
> with all their properties in the following examples. I would
> appreciate some direction on how to proceed.
>
>
> @foo1
> @foo2()
> @foo3(anything could go here)

You can find regular expression primers all over the internet - fire
up your favorite search engine and type those three words in. But it
may be that what you want here is a more flexible parser; have you
looked at BeautifulSoup (so rich and green)?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Regex Question

2012-08-17 Thread Frank Koshti
Hi,

I'm new to regular expressions. I want to be able to match for tokens
with all their properties in the following examples. I would
appreciate some direction on how to proceed.


@foo1
@foo2()
@foo3(anything could go here)


Thanks-
Frank
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Steven D'Aprano
On Fri, 17 Aug 2012 23:30:22 -0400, Dave Angel wrote:

> On 08/17/2012 08:21 PM, Ian Kelly wrote:
>> On Aug 17, 2012 2:58 PM, "Dave Angel"  wrote:
>>> The internal coding described in PEP 393 has nothing to do with
>>> latin-1 encoding.
>> It certainly does. PEP 393 provides for Unicode strings to be
>> represented internally as any of Latin-1, UCS-2, or UCS-4, whichever is
>> smallest and sufficient to contain the data. 

Unicode strings are not represented as Latin-1 internally. Latin-1 is a 
byte encoding, not a unicode internal format. Perhaps you mean to say 
that they are represented as a single byte format?

>> I understand the complaint
>> to be that while the change is great for strings that happen to fit in
>> Latin-1, it is less efficient than previous versions for strings that
>> do not.
> 
> That's not the way I interpreted the PEP 393.  It takes a pure unicode
> string, finds the largest code point in that string, and chooses 1, 2 or
> 4 bytes for every character, based on how many bits it'd take for that
> largest code point.

That's how I interpret it too.


> Further i read it to mean that only 00 bytes would
> be dropped in the process, no other bytes would be changed.

Just to clarify, you aren't talking about the \0 character, but only to 
extraneous "padding" 00 bytes.


> I also figure this is going to be more space efficient than Python 3.2
> for any string which had a max code point of 65535 or less (in Windows),
> or 4billion or less (in real systems).  So unless French has code points
> over 64k, I can't figure that anything is lost.

I think that on narrow builds, it won't make terribly much difference. 
The big savings are for wide builds.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Steven D'Aprano
On Fri, 17 Aug 2012 11:45:02 -0700, wxjmfauth wrote:

> Le vendredi 17 août 2012 20:21:34 UTC+2, Jerry Hill a écrit :
>> On Fri, Aug 17, 2012 at 1:49 PM,   wrote:
>> 
>> > The character '…', Unicode name 'HORIZONTAL ELLIPSIS',
>> > is one of these characters existing in the cp1252, mac-roman
>> > coding schemes and not in iso-8859-1 (latin-1) and obviously
>> > not in ascii. It causes Py3.3 to work a few 100% slower
>> > than Py<3.3 versions due to the flexible string representation
>> > (ascii/latin-1/ucs-2/ucs-4) (I found cases up to 1000%).
[...]
> Sorry, you missed the point.
> 
> My comment had nothing to do with the code source coding, the coding of
> a Python "string" in the code source or with the display of a Python3
> .
> I wrote about the *internal* Python "coding", the way Python keeps
> "strings" in memory. See PEP 393.


The PEP does not support your claim that flexible string storage is 100% 
to 1000% slower. It claims 1% - 30% slowdown, with a saving of up to 60% 
of the memory used for strings.

I don't really understand what message you are trying to give here. Are 
you saying that PEP 393 is a good thing or a bad thing?

In Python 1.x, there was no support for Unicode at all. You could only 
work with pure byte strings. Support for non-ascii characters like … ∞ é ñ
£ π Ж ش was purely by accident -- if your terminal happened to be set to 
an encoding that supported a character, and you happened to use the 
appropriate byte value, you might see the character you wanted.

In Python 2.2, Python gained support for Unicode. You could now guarantee 
support for any Unicode character in the Basic Multilingual Plane (BMP) 
by writing your strings using the u"..." style. In Python 3, you no 
longer need the leading U, all strings are unicode.

But there is a problem: if your Python interpreter is a "narrow build", 
it *only* supports Unicode characters in the BMP. When Python is a "wide 
build", compiled with support for the additional character planes, then 
strings take much more memory, even if they are in the BMP, or are simple 
ASCII strings.

PEP 393 fixes this problem and gets rid of the distinction between narrow 
and wide builds. From Python 3.3 onwards, all Python compilers will have 
the same support for unicode, rather than most being BMP-only. Each 
individual string's internal storage will use only as many bytes-per-
character as needed to store the largest character in the string.

This will save a lot of memory for those using mostly ASCII or Latin-1 
but a few multibyte characters. While the increased complexity causes a 
small slowdown, the increased functionality makes it well worthwhile.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Dave Angel
On 08/17/2012 08:21 PM, Ian Kelly wrote:
> On Aug 17, 2012 2:58 PM, "Dave Angel"  wrote:
>> The internal coding described in PEP 393 has nothing to do with latin-1
>> encoding.
> It certainly does. PEP 393 provides for Unicode strings to be represented
> internally as any of Latin-1, UCS-2, or UCS-4, whichever is smallest and
> sufficient to contain the data. I understand the complaint to be that while
> the change is great for strings that happen to fit in Latin-1, it is less
> efficient than previous versions for strings that do not.

That's not the way I interpreted the PEP 393.  It takes a pure unicode
string, finds the largest code point in that string, and chooses 1, 2 or
4 bytes for every character, based on how many bits it'd take for that
largest code point.   Further i read it to mean that only 00 bytes would
be dropped in the process, no other bytes would be changed.   I take it
as a coincidence that it happens to match latin-1;  that's the way
Unicode happened historically, and is not Python's fault.  Am I reading
it wrong?

I also figure this is going to be more space efficient than Python 3.2
for any string which had a max code point of 65535 or less (in Windows),
or 4billion or less (in real systems).  So unless French has code points
over 64k, I can't figure that anything is lost.

I have no idea about the times involved, so i wanted a more specific
complaint.

> I don't know how much merit there is to this claim. It would seem to me
> that even in non-western locales, most strings are likely to be Latin-1 or
> even ASCII, e.g.  class and attribute and function names.
>
>

The jmfauth rant I was responding to was saying that French isn't
efficiently encoded, and that performance of some vague operations were
somehow reduced by several fold.  I was just trying to get him to be
more specific.



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crashes always on Windows 7

2012-08-17 Thread zmagic11
On Friday, August 17, 2012 9:38:16 PM UTC+8, zmag...@gmail.com wrote:
> Hi,
> 
> 
> 
> Downloaded ActiveSync ActivePython on my Windows 7 machine. Worked for a 
> little while and now it crashes every time I try to boot the IDLE or open a 
> program, it crashes. Help please? Thanks

Hi Hi, sorry for the confusion. Yes, I meant ActiveState ActivePython. It 
worked fine for a few hours and now every time I open up the IDLE Shell, it 
opens fine. Then when I try to open a previously made file, the shell 
immediately closes and nothing else happens. When I enter Python in the command 
line, I get the ActivePython information. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread Zero Piraeus
:

On 17 August 2012 21:43, Steven D'Aprano
 wrote:
> There are cultures that marry five year old girls to sixty year old men,
> cultures that treat throwing acid in the faces of women as acceptable
> behaviour, cultures that allow war heroes to die of hunger and cold
> homeless in the street, and cultures that top-post. What's your point?

+1 QOTW

 -[]z.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread Steven D'Aprano
On Fri, 17 Aug 2012 09:36:04 -0700, rusi wrote:

> I was in a corporate environment for a while.  And carried my
> 'trim&interleave' habits there.
> And got gently scolded for seeming to hide things!!

Corporate email users are generally incompetent at email no matter what 
email conventions you use. I cannot tell you the number of times I have 
emailed somebody, top-posted, explicitly said "We have three questions 
blocking progress, please answer all three", asked the three questions in 
clearly numbered bullet points... and got an answer back to the first and 
not even an acknowledgement of the other two.

Nevertheless, I've taken up writing at the top of emails

"My replies are interleaved with your questions which are shown starting 
with > symbols."

to make it obvious that they should keep reading.

It *is* possible to top-post and communicate effectively, it just takes a 
LOT more work, and the sorts of people who prefer top posting simply 
don't do it. Top-posting only works for shallow communication: simple 
questions, simple replies, and shallow threads, two or three replies at 
most. It's good for emails like:

Subject: Meet you at the pub on Friday afternoon?

See u there!!!

--- Original Message ---

Hey bro, want to catch up for drinks at the pub on Friday? 


but lousy for long *discussion* threads where people are replying to 
potentially dozens of separate issues within a single email.

To communicate effectively in email, you need to assume that your reader 
has forgotten the context of your reply, since they may have. They are 
probably dealing with dozens of other similar emails. A thread may go on 
for a week, or the question may have been asked a month ago and the reply 
only sent now. In long discussions, subjects may drift so that the 
subject line is no longer appropriate, or it may be a generic subject 
line.

In interleaved email, the quoted text acts as a refresher of previous 
content. If you don't interleave, you are responsible for adding context. 
Rather than:

"Sort the list first."

write something like:

"Your binary search is failing because the list is unsorted. Sort the 
list first."

That's a trivial example. In practice this becomes a PITA real fast, 
which is why top-posting discourages discussion in depth and encourages 
short, shallow, context-free replies.


> Just mentioning that there are cultures other than this one.

There are cultures that marry five year old girls to sixty year old men, 
cultures that treat throwing acid in the faces of women as acceptable 
behaviour, cultures that allow war heroes to die of hunger and cold 
homeless in the street, and cultures that top-post. What's your point?


> Of course, "Do in Rome as romans do" is universally sound advice, (with
> Rome suitably parameterized), so its best to follow the netiquette of
> the forum you are using.

Unless you think you can change the culture of Rome by example.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically determine base classes on instantiation

2012-08-17 Thread Steven D'Aprano
On Fri, 17 Aug 2012 04:50:43 -0700, Richard Thomas wrote:

> On Thursday, 16 August 2012 19:49:43 UTC+2, Steven D'Aprano  wrote:
>> On Thu, 16 Aug 2012 10:03:51 -0700, Richard Thomas wrote:
>> 
>> > class Foo(object):
>> > def __new__(cls, arg):
>> > if isinstance(arg, list):
>> > cls = FooList
>> > elif isinstance(arg, dict):
>> > cls = FooDict
>> > return object.__new__(cls, arg)
>> > 
>> > class FooList(Foo, list):
>> > pass
>> > 
>> > class FooDict(Foo, dict):
>> > pass
>>
>>
>> Did you actually try your code?
>>
>>
> I rarely test code. I'm confident in, however undeserved the confidence.
> :) In this case that's not an error I've ever seen before. Obvious easy
> fix:
> 
> return cls.__new__(cls, arg)

It might be easy, but it's obviously wrong.

py> sys.setrecursionlimit(10)
py> x = Foo([])
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 7, in __new__
  File "", line 7, in __new__
  File "", line 7, in __new__
  File "", line 7, in __new__
  File "", line 7, in __new__
  File "", line 7, in __new__
  File "", line 7, in __new__
RuntimeError: maximum recursion depth exceeded


> Incidentally when I reply to your posts through the groups.google.com
> interface it inserts a blank quoted line between each pair of lines. My
> first thought was that it was a line endings bug with Google's app but
> in retrospect that seems very likely to have been fixed years ago. Any
> ideas?

Makes you think that Google is interested in fixing the bugs in their 
crappy web apps? They have become as arrogant and as obnoxious as 
Microsoft used to be.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Ian Kelly
On Aug 17, 2012 2:58 PM, "Dave Angel"  wrote:
>
> The internal coding described in PEP 393 has nothing to do with latin-1
> encoding.

It certainly does. PEP 393 provides for Unicode strings to be represented
internally as any of Latin-1, UCS-2, or UCS-4, whichever is smallest and
sufficient to contain the data. I understand the complaint to be that while
the change is great for strings that happen to fit in Latin-1, it is less
efficient than previous versions for strings that do not.

I don't know how much merit there is to this claim. It would seem to me
that even in non-western locales, most strings are likely to be Latin-1 or
even ASCII, e.g.  class and attribute and function names.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread Christian Heimes
Am 17.08.2012 21:20, schrieb wdt...@comcast.net:
> Just installed python 2.7 and using with web2py.  
> 
> When running python from command line to bring up web2py server, get errors 
> that python socket and urllib modules cannot be found, can't be loaded. This 
> is not a web2py issue.
> 
> No other python versions are on the my machine.  Pythonpath has the requisite 
> folders identified.

Please show us the output of:

import sys
print sys.version

import platform
print platform.platform()

import imp
print imp.find_module("_socket")

imp.find_module() may either return "_socket" as first argument if the
_socket module is builtin or return the full path to a file. When it's a
full path please install http://www.dependencywalker.com/ and examine
the _socket.pyd file with the tool. It will show you the missing DLLs.

Christian


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread Emile van Sebille

On 8/17/2012 2:22 PM wdt...@comcast.net said...

Done - tail end of the python path had a missing bit...gr... thanks so much


Well it's bizarre - now it doesn't.  did an import sys from within interpreter, 
then did import socket.  Worked the first time.  Restarted and it happened 
again.  The sys.path outputs are identical.  The print socket.__file__ reveals 
a file that is in the sys.path...g.




Next, I'd check for rogue versions of _socket.pyd in directories 
occuring in sys.path.


Emile


--
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Chris Angelico
On Sat, Aug 18, 2012 at 4:37 AM, Aaron Brady  wrote:
> Is there a problem with hacking on the Beta?

Nope. Hack on the beta, then when the release arrives, rebase your
work onto it. I doubt that anything of this nature will be changed
between now and then.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread wdtate
On Friday, August 17, 2012 3:20:48 PM UTC-4, (unknown) wrote:
> Just installed python 2.7 and using with web2py.  
> 
> 
> 
> When running python from command line to bring up web2py server, get errors 
> that python socket and urllib modules cannot be found, can't be loaded. This 
> is not a web2py issue.
> 
> 
> 
> No other python versions are on the my machine.  Pythonpath has the requisite 
> folders identified.
> 
> 
> 
> Would appreciate any insights as to what may be happening.
> 
> 
> 
> thanks in advance

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread wdtate
On Friday, August 17, 2012 5:15:35 PM UTC-4, (unknown) wrote:
> > 
> 
> > So, try the following in both environments:
> 
> >  import sys
> 
> >  for ii in sys.path: print ii
> 
> >
> 
> > You'll likely find diffferences between the two.
> 
> 
> 
> > In the pythonwin environment, try:
> 
> > 
> 
> > 
> 
> > 
> 
> >  import socket
> 
> > 
> 
> >  print socket.__file__
> 
> > 
> 
> > 
> 
> > Chances are the __file__'s directory isn't in the command line's sys.path.
> 
> > 
> 
> > 
> 
> > 
> 
> > Emile
> 
> 
> 
> Done - tail end of the python path had a missing bit...gr... thanks so 
> much

Well it's bizarre - now it doesn't.  did an import sys from within interpreter, 
then did import socket.  Worked the first time.  Restarted and it happened 
again.  The sys.path outputs are identical.  The print socket.__file__ reveals 
a file that is in the sys.path...g.


On Friday, August 17, 2012 5:15:35 PM UTC-4, (unknown) wrote:
> > 
> 
> > So, try the following in both environments:
> 
> >  import sys
> 
> >  for ii in sys.path: print ii
> 
> >
> 
> > You'll likely find diffferences between the two.
> 
> 
> 
> > In the pythonwin environment, try:
> 
> > 
> 
> > 
> 
> > 
> 
> >  import socket
> 
> > 
> 
> >  print socket.__file__
> 
> > 
> 
> > 
> 
> > Chances are the __file__'s directory isn't in the command line's sys.path.
> 
> > 
> 
> > 
> 
> > 
> 
> > Emile
> 
> 
> 
> Done - tail end of the python path had a missing bit...gr... thanks so 
> much



On Friday, August 17, 2012 5:15:35 PM UTC-4, (unknown) wrote:
> > 
> 
> > So, try the following in both environments:
> 
> >  import sys
> 
> >  for ii in sys.path: print ii
> 
> >
> 
> > You'll likely find diffferences between the two.
> 
> 
> 
> > In the pythonwin environment, try:
> 
> > 
> 
> > 
> 
> > 
> 
> >  import socket
> 
> > 
> 
> >  print socket.__file__
> 
> > 
> 
> > 
> 
> > Chances are the __file__'s directory isn't in the command line's sys.path.
> 
> > 
> 
> > 
> 
> > 
> 
> > Emile
> 
> 
> 
> Done - tail end of the python path had a missing bit. Corrected that.  the 
> sys.path outputs match but I still have the same problem.  

print socket.__file__ produces a path that is in the pythonpath.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread wdtate
> 
> So, try the following in both environments:
>  import sys
>  for ii in sys.path: print ii
>
> You'll likely find diffferences between the two.

> In the pythonwin environment, try:
> 
> 
> 
>  import socket
> 
>  print socket.__file__
> 
> 
> Chances are the __file__'s directory isn't in the command line's sys.path.
> 
> 
> 
> Emile

Done - tail end of the python path had a missing bit...gr... thanks so much
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread Emile van Sebille

On 8/17/2012 1:41 PM wdt...@comcast.net said...

From cmd prompt - I get this:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.

import urllib

Traceback (most recent call last):
   File "", line 1, in 
   File "C:\Python27\lib\urllib.py", line 26, in 
 import socket
   File "C:\Python27\lib\socket.py", line 47, in 
 import _socket
ImportError: DLL load failed: The specified module could not be found

I also get that if I attempt to import socket.

NOTE this does not happen when I'm in the pythonwin IDE.





So, try the following in both environments:

import sys
for ii in sys.path: print ii

You'll likely find diffferences between the two.


In the pythonwin environment, try:

import socket
print socket.__file__


Chances are the __file__'s directory isn't in the command line's sys.path.

Emile




--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Dave Angel
On 08/17/2012 02:45 PM, wxjmfa...@gmail.com wrote:
> Le vendredi 17 août 2012 20:21:34 UTC+2, Jerry Hill a écrit :
>> 
>>
>> I don't understand what any of this has to do with Python.  Just
>>
>> output your text in UTF-8 like any civilized person in the 21st
>>
>> century, and none of that is a problem at all.  Python make that easy.
>>
>>  It also makes it easy to interoperate with older encodings if you
>>
>> have to.
>>
> Sorry, you missed the point.
>
> My comment had nothing to do with the code source coding,
> the coding of a Python "string" in the code source or with
> the display of a Python3 .
> I wrote about the *internal* Python "coding", the
> way Python keeps "strings" in memory. See PEP 393.
>
> jmf

The internal coding described in PEP 393 has nothing to do with latin-1
encoding.  So what IS your point?  Make it clearly, without all the
snide side-comments.



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread wdtate
> 
> So, on my system I get:
> 
> ActivePython 2.7.0.2 (ActiveState Software Inc.) based on
> 
> Python 2.7 (r27:82500, Aug 23 2010, 17:18:21) [MSC v.1500 32 bit 
> 
> (Intel)] on win32
> 
> Type "help", "copyright", "credits" or "license" for more information.
> 
>  >>> import urllib
> 
>  >>> import socket
> 
>  >>>
> 
> 
> 
> What does your system show?
> 
> 
> 
> Emile
> 
>From cmd prompt - I get this:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\urllib.py", line 26, in 
import socket
  File "C:\Python27\lib\socket.py", line 47, in 
import _socket
ImportError: DLL load failed: The specified module could not be found

I also get that if I attempt to import socket.

NOTE this does not happen when I'm in the pythonwin IDE.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread Emile van Sebille

On 8/17/2012 12:20 PM wdt...@comcast.net said...

Just installed python 2.7 and using with web2py.

When running python from command line to bring up web2py server, get errors 
that python socket and urllib modules cannot be found, can't be loaded. This is 
not a web2py issue.



So, on my system I get:


ActivePython 2.7.0.2 (ActiveState Software Inc.) based on
Python 2.7 (r27:82500, Aug 23 2010, 17:18:21) [MSC v.1500 32 bit 
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> import socket
>>>

What does your system show?

Emile



No other python versions are on the my machine.  Pythonpath has the requisite 
folders identified.

Would appreciate any insights as to what may be happening.

thanks in advance




--
http://mail.python.org/mailman/listinfo/python-list


Python 2.7 import socket urllib fails to load, module not found

2012-08-17 Thread wdtate
Just installed python 2.7 and using with web2py.  

When running python from command line to bring up web2py server, get errors 
that python socket and urllib modules cannot be found, can't be loaded. This is 
not a web2py issue.

No other python versions are on the my machine.  Pythonpath has the requisite 
folders identified.

Would appreciate any insights as to what may be happening.

thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ONLINE SERVER TO STORE AND RUN PYTHON SCRIPTS

2012-08-17 Thread Ian Kelly
On Fri, Aug 17, 2012 at 6:46 AM, coldfire  wrote:
> I would like to know that where can a python script be stored on-line from 
> were it keep running and can be called any time when required using internet.
> I have used mechanize module which creates a webbroswer instance to open a 
> website and extract data and email me.
> I have tried Python anywhere but they dont support opening of anonymous 
> websites.

According to their FAQ they don't support this for *free* accounts.
You could just open a paid account (the cheapest option appears to be
$5/month).

Also, please don't type your email subject in all capital letters.  It
comes across as shouting and is considered rude.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSLSocket.getpeercert() doesn't return issuer, serial number, etc

2012-08-17 Thread Gustavo Baratto
Awesome guys! Thank you very much!

I ended up using "binary_form=True" and using M2Crypto to parse the cert.

Cheers,
g.

On Thu, Aug 16, 2012 at 4:48 AM, Antoine Pitrou  wrote:

>
> Hello,
>
> Gustavo Baratto  gmail.com> writes:
> >
> > SSL.Socket.getpeercert() doesn't return essential information present in
> the
> > client certificate (issuer, serial number, not before, etc), and it
> looks it is
> > by design:
>
> It does, in Python 3.2:
> http://docs.python.org/py3k/library/ssl.html#client-side-operation
>
> (although the getpeercert() doc should be updated to reflect this)
>
> If some information is still lacking from the returned value, please open
> an
> issue at http://bugs.python.org
>
> Regards
>
> Antoine.
>
>
> --
> Software development and contracting: http://pro.pitrou.net
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread wxjmfauth
Le vendredi 17 août 2012 20:21:34 UTC+2, Jerry Hill a écrit :
> On Fri, Aug 17, 2012 at 1:49 PM,   wrote:
> 
> > The character '…', Unicode name 'HORIZONTAL ELLIPSIS',
> 
> > is one of these characters existing in the cp1252, mac-roman
> 
> > coding schemes and not in iso-8859-1 (latin-1) and obviously
> 
> > not in ascii. It causes Py3.3 to work a few 100% slower
> 
> > than Py<3.3 versions due to the flexible string representation
> 
> > (ascii/latin-1/ucs-2/ucs-4) (I found cases up to 1000%).
> 
> >
> 
>  '…'.encode('cp1252')
> 
> > b'\x85'
> 
>  '…'.encode('mac-roman')
> 
> > b'\xc9'
> 
>  '…'.encode('iso-8859-1') # latin-1
> 
> > Traceback (most recent call last):
> 
> >   File "", line 1, in 
> 
> > UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026'
> 
> > in position 0: ordinal not in range(256)
> 
> >
> 
> > If one could neglect this (typographically important) glyph, what
> 
> > to say about the characters of the European scripts (languages)
> 
> > present in cp1252 or in mac-roman but not in latin-1 (eg. the
> 
> > French script/language)?
> 
> 
> 
> So... python should change the longstanding definition of the latin-1
> 
> character set?  This isn't some sort of python limitation, it's just
> 
> the reality of legacy encodings that actually exist in the real world.
> 
> 
> 
> 
> 
> > Very nice. Python 2 was built for ascii user, now Python 3 is
> 
> > *optimized* for, let say, ascii user!
> 
> >
> 
> > The future is bright for Python. French users are better
> 
> > served with Apple or MS products, simply because these
> 
> > corporates know you can not write French with iso-8859-1.
> 
> >
> 
> > PS When "TeX" moved from the ascii encoding to iso-8859-1
> 
> > and the so called Cork encoding, "they" know this and provided
> 
> > all the complementary packages to circumvent this. It was
> 
> > in 199? (Python was not even born).
> 
> >
> 
> > Ditto for the foundries (Adobe, Linotype, ...)
> 
> 
> 
> 
> 
> I don't understand what any of this has to do with Python.  Just
> 
> output your text in UTF-8 like any civilized person in the 21st
> 
> century, and none of that is a problem at all.  Python make that easy.
> 
>  It also makes it easy to interoperate with older encodings if you
> 
> have to.
> 

Sorry, you missed the point.

My comment had nothing to do with the code source coding,
the coding of a Python "string" in the code source or with
the display of a Python3 .
I wrote about the *internal* Python "coding", the
way Python keeps "strings" in memory. See PEP 393.

jmf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 9:24:44 PM UTC-5, Steven D'Aprano wrote:
> On Thu, 16 Aug 2012 19:11:19 -0400, Dave Angel wrote:
> 
> 
> 
> > On 08/16/2012 05:26 PM, Paul Rubin wrote:
> 
> >> Dave Angel  writes:
> 
> >>> Everything else is implementation defined.  Why should an
> 
> >>> implementation be forced to have ANY extra data structure to detect a
> 
> >>> static bug in the caller's code?
> 
> >> For the same reason the interpreter checks for type errors at runtime
> 
> >> and raises TypeError, instead of letting the program go into the weeds.
> 
> > 
> 
> > There's an enormous difference between type errors, which affect the low
> 
> > level dispatch, and checking for whether a dict has changed and may have
> 
> > invalidated the iterator.  If we were really going to keep track of what
> 
> > iterators are tracking a given dict or set, why stop there?  Why not
> 
> > check if another process has changed a file we're iterating through?  Or
> 
> > ...
> 
> 
> 
> Which is why Python doesn't do it -- because it is (claimed to be) 
> 
> excessively expensive for the benefit that you would get.
> 
> 
> 
> Not because it is a matter of principle that data integrity is 
> 
> unimportant. Data integrity *is* important, but in the opinion of the 
> 
> people who wrote these particular data structures, the effort required to 
> 
> guarantee correct iteration in the face of mutation is too expensive for 
> 
> the benefit.
> 
> 
> 
> Are they right? I don't know. I know that the list sort method goes to a 
> 
> lot of trouble to prevent code from modifying lists while they are being 
> 
> sorted. During the sort, the list temporarily appears to be empty to 
> 
> anything which attempts to access it. So at least sometimes, the Python 
> 
> developers spend effort to ensure data integrity.
> 
> 
> 
> Luckily, Python is open source. If anyone thinks that sets and dicts 
> 
> should include more code protecting against mutation-during-iteration, 
> 
> they are more than welcome to come up with a patch. Don't forget unit and 
> 
> regression tests, and also a set of timing results which show that the 
> 
> slow-down isn't excessive.

I contribute a patch some time ago.  It wasn't accepted.  However this thread 
seems to show a moderately more favorable sentiment than that one.

Is there a problem with hacking on the Beta?  Or should I wait for the Release? 
 Does anyone want to help me with the changes?  Perhaps P. Rubin could 
contribute the variation he suggested as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread Jerry Hill
On Fri, Aug 17, 2012 at 1:49 PM,   wrote:
> The character '…', Unicode name 'HORIZONTAL ELLIPSIS',
> is one of these characters existing in the cp1252, mac-roman
> coding schemes and not in iso-8859-1 (latin-1) and obviously
> not in ascii. It causes Py3.3 to work a few 100% slower
> than Py<3.3 versions due to the flexible string representation
> (ascii/latin-1/ucs-2/ucs-4) (I found cases up to 1000%).
>
 '…'.encode('cp1252')
> b'\x85'
 '…'.encode('mac-roman')
> b'\xc9'
 '…'.encode('iso-8859-1') # latin-1
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026'
> in position 0: ordinal not in range(256)
>
> If one could neglect this (typographically important) glyph, what
> to say about the characters of the European scripts (languages)
> present in cp1252 or in mac-roman but not in latin-1 (eg. the
> French script/language)?

So... python should change the longstanding definition of the latin-1
character set?  This isn't some sort of python limitation, it's just
the reality of legacy encodings that actually exist in the real world.


> Very nice. Python 2 was built for ascii user, now Python 3 is
> *optimized* for, let say, ascii user!
>
> The future is bright for Python. French users are better
> served with Apple or MS products, simply because these
> corporates know you can not write French with iso-8859-1.
>
> PS When "TeX" moved from the ascii encoding to iso-8859-1
> and the so called Cork encoding, "they" know this and provided
> all the complementary packages to circumvent this. It was
> in 199? (Python was not even born).
>
> Ditto for the foundries (Adobe, Linotype, ...)


I don't understand what any of this has to do with Python.  Just
output your text in UTF-8 like any civilized person in the 21st
century, and none of that is a problem at all.  Python make that easy.
 It also makes it easy to interoperate with older encodings if you
have to.

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 9:30:42 PM UTC-5, Paul Rubin wrote:
> Steven D'Aprano  writes:
> 
> > Luckily, Python is open source. If anyone thinks that sets and dicts 
> 
> > should include more code protecting against mutation-during-iteration, 
> 
> > they are more than welcome to come up with a patch. Don't forget unit and 
> 
> > regression tests, and also a set of timing results which show that the 
> 
> > slow-down isn't excessive.
> 
> 
> 
> It could be a debugging option, in which case even a fairly significant
> 
> slowdown is acceptable.

Another possibility is to use the 'gc.get_referrers' mechanism to obtain the 
iterators.


import gc
a= set( ( 0, 1, 2 ) )
b= iter( a )
c= iter( a )
d= iter( a )
print( gc.get_referrers( a ) )

Output:

[, , 
, [others] ]

This approach wouldn't be as time-efficient as a dedicated secondary structure, 
due to the other objects which refer to the set, including variable namespaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 8:01:39 PM UTC-5, Paul Rubin wrote:
> Ian Kelly  writes:
> 
> > With regard to key insertion and deletion while iterating over a dict
> 
> > or set, though, there is just no good reason to be doing that
> 
> > (especially as the result is very implementation-specific), and I
> 
> > wouldn't mind a more complete low-level check against it as long as
> 
> > it's not too expensive (which is not clearly the case with the current
> 
> > suggestion at all).
> 
> 
> 
> One possible approach is to freeze the dictionary against modification
> 
> while any iterator is open on it.  You could keep a count of active
> 
> iterators in the dict structure, adjusting it whenever an iterator is
> 
> created or closed/destroyed.

Good point.  Your approach is another consistent solution.

The difference is in where the exception is raised.  Invalidating the iterators 
raises an exception when they're called.  Locking the set/dict raises an 
exception on 'add' and 'remove' calls.

The latter also forces additional statements to delete iterators before they 
leave scope in some cases.  We wouldn't be able to make modifications in a 
'for' suite, even if followed by a 'break', which could be a problem for 
existing code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Aaron Brady
On Thursday, August 16, 2012 6:07:40 PM UTC-5, Ian wrote:
> On Thu, Aug 16, 2012 at 4:55 PM, Ian Kelly  wrote:
> 
> > On Thu, Aug 16, 2012 at 12:00 PM, Aaron Brady  wrote:
> 
> >> The inconsistency is, if we remove an element from a set and add another 
> >> during iteration, the new element might appear later in the iteration, and 
> >> might not, depending on the hash code; therefore comparing the size of the 
> >> set between iterations isn't adequate.  Example:
> 
> >
> 
> > It can be more than just the new element.  For example, here the
> 
> > entire set is repeated (Python 3.2):
> 
> >
> 
>  s = set(range(8, 13))
> 
>  it = iter(s)
> 
>  from itertools import islice
> 
>  list(islice(it, 5))  # avoid exhausting the iterator
> 
> > [8, 9, 10, 11, 12]
> 
>  s.add(13)
> 
>  s.remove(13)
> 
>  list(it)
> 
> > [8, 9, 10, 11, 12]
> 
> >
> 
> > This occurs because the addition of the sixth item triggers a resize
> 
> > of the underlying hash table, and the existing items, which were
> 
> > originally in slots 0-4, are now in slots 8-12.
> 
> 
> 
> Another curious example:
> 
> 
> 
> >>> s = set(range(8, 48, 8))
> 
> >>> s
> 
> {8, 16, 40, 24, 32}
> 
> >>> it = iter(s)
> 
> >>> from itertools import islice
> 
> >>> list(islice(it, 4))
> 
> [8, 16, 40, 24]
> 
> >>> s.add(48)
> 
> >>> s.remove(48)
> 
> >>> list(it)
> 
> [8, 16, 40, 24]
> 
> 
> 
> Hey, what happened to 32?

Good examples.  The former occurs without the 'islice' as well.

s= set( range( 8, 13 ) ) 
it= iter( s ) 
print( [ next( it ) for _ in range( 5 ) ] )
s.add( 13 ) 
s.remove( 13 ) 
print( [ next( it ) for _ in range( 5 ) ] )

Output:

[8, 9, 10, 11, 12]
[8, 9, 10, 11, 12]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-17 Thread wxjmfauth
Le vendredi 17 août 2012 01:59:31 UTC+2, Terry Reedy a écrit :
> a = '…'
> 
> print(ord(a))
> 
>  >>>
> 
> 8230
> 
> Most things with unicode are easier in 3.x, and some are even better in 
> 
> 3.3. The current beta is good enough for most informal work. 3.3.0 will 
> 
> be out in a month.
> 
> 
> 
> -- 
> 
> Terry Jan Reedy

Slightly off topic.

The character '…', Unicode name 'HORIZONTAL ELLIPSIS',
is one of these characters existing in the cp1252, mac-roman
coding schemes and not in iso-8859-1 (latin-1) and obviously
not in ascii. It causes Py3.3 to work a few 100% slower
than Py<3.3 versions due to the flexible string representation
(ascii/latin-1/ucs-2/ucs-4) (I found cases up to 1000%).

>>> '…'.encode('cp1252')
b'\x85'
>>> '…'.encode('mac-roman')
b'\xc9'
>>> '…'.encode('iso-8859-1') # latin-1
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026'
in position 0: ordinal not in range(256)

If one could neglect this (typographically important) glyph, what
to say about the characters of the European scripts (languages)
present in cp1252 or in mac-roman but not in latin-1 (eg. the
French script/language)?

Very nice. Python 2 was built for ascii user, now Python 3 is
*optimized* for, let say, ascii user!

The future is bright for Python. French users are better
served with Apple or MS products, simply because these
corporates know you can not write French with iso-8859-1.

PS When "TeX" moved from the ascii encoding to iso-8859-1
and the so called Cork encoding, "they" know this and provided
all the complementary packages to circumvent this. It was
in 199? (Python was not even born).

Ditto for the foundries (Adobe, Linotype, ...)

jmf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crashes always on Windows 7

2012-08-17 Thread Ian Kelly
On Aug 17, 2012 8:58 AM, "Dave Angel"  wrote:
>
> Also, please tell us the versions involved, and in the case of
> ActiveSync, where you got it.
>
> http://sourceforge.net/apps/trac/unattended/wiki/ActiveSync
> seems to be perl related, not Python.
>
> Presumably you mean the Microsoft product (no idea what that has to do
> with Python), but according to one source:
>
>
> "Microsoft ActiveSync (Superceded By Windows Mobile Device
> Center)"

I'm sure the OP meant ActiveState, not ActiveSync.

To the OP: your problen statement is quite vague. Have you tried
uninstalling and reinstalling ActivePython?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread rusi
On Aug 17, 10:19 am, Dennis Lee Bieber  wrote:
> On Thu, 16 Aug 2012 15:42:54 -0700 (PDT), Madison May
>  declaimed the following in
> gmane.comp.python.general:
>
>
>
> > As a lurker, I agree completely with Chris's sentiments.
>
>         I've been holding back on quoting the "netiquette RFC"... I also
> tend to blame M$ (Outlook and variants) for this tendency to quote
> everything and top-post -- Outlook makes it almost impossible to do a
> trim&interleave response style.
>
>         Including everything as a trailing quote may be okay in an office
> environment, where it serves more as a photocopy included with an paper
> mail response.

I was in a corporate environment for a while.  And carried my
'trim&interleave' habits there.
And got gently scolded for seeming to hide things!!

Just mentioning that there are cultures other than this one.

Of course, "Do in Rome as romans do" is universally sound advice,
(with Rome suitably parameterized), so its best to follow the
netiquette of the forum you are using.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Gilles
On Fri, 17 Aug 2012 14:44:37 +0100, Robert Kern
 wrote:
>> For some reason, this CGI script that I found on Google displays the
>> contents of the variable but the HTML surrounding it is displayed
>> as-is by the browser instead of being rendered

Thanks all. I (obviously) combined two scripts but didn't notice that
I had to change the "Content-Type" line to output HTML.
-- 
http://mail.python.org/mailman/listinfo/python-list


pythonic interface to SAPI5?

2012-08-17 Thread Vojtěch Polášek
Hi,
I am developing audiogame for visually impaired users and I want it to
be multiplatform. I know, that there is library called accessible_output
but it is not working when used in Windows for me.
I tried pyttsx, which should use Espeak on Linux and SAPI5 on Windows.
It works on Windows, on Linux I decided to use speech dispatcher bindings.
But it seems that I can't interrupt speech when using pyttsx and this is
showstopper for me.
Does anyone has any working solution for using SAPI5 on windows?
Thank you very much,
Vojta
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crashes always on Windows 7

2012-08-17 Thread Dave Angel
On 08/17/2012 09:38 AM, zmagi...@gmail.com wrote:
> Hi,
>
> Downloaded ActiveSync ActivePython on my Windows 7 machine. Worked for a 
> little while and now it crashes every time I try to boot the IDLE or open a 
> program, it crashes. Help please? Thanks

I'm not aware of any boot option for Windows that involves IDLE.  And
why Notepad and Internet Explorer should suddenly crash, I have no idea.

How about some more details?  What messages do you get in your console
window when you run "a program" ?  Please cut and paste the whole
message, no paraphrasing.

Also, please tell us the versions involved, and in the case of
ActiveSync, where you got it.

http://sourceforge.net/apps/trac/unattended/wiki/ActiveSync
seems to be perl related, not Python.

Presumably you mean the Microsoft product (no idea what that has to do
with Python), but according to one source:


"Microsoft ActiveSync (Superceded By Windows Mobile Device
Center)"

-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remote read eval print loop

2012-08-17 Thread Chris Angelico
On Fri, Aug 17, 2012 at 11:28 PM, Eric Frederich
 wrote:
> Within the debugging console, after importing all of the bindings, there
> would be no reason to import anything whatsoever.
> With just the bindings I created and the Python language we could do
> meaningful debugging.
> So if I block the ability to do any imports and calls to eval I should be
> safe right?

Nope. Python isn't a secured language in that way. I tried the same
sort of thing a while back, but found it effectively impossible. (And
this after people told me "It's not possible, don't bother trying". I
tried anyway. It wasn't possible.)

If you really want to do that, consider it equivalent to putting an
open SSH session into your debugging console. Would you give that much
power to your application's users? And if you would, is it worth
reinventing SSH?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Alexander Blinne
On 17.08.2012 15:27, Gilles wrote:
> For some reason, this CGI script that I found on Google displays the
> contents of the variable but the HTML surrounding it is displayed
> as-is by the browser instead of being rendered:

> print "Content-Type: text/plain;charset=utf-8"

With this line you tell the browser to expect a simple plain text file
and no html. Change the line to

print "Content-Type: text/html;charset=utf-8"

and it should work.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Robert Kern

On 8/17/12 2:27 PM, Gilles wrote:

Hello

I'm learning how to call Python scripts through the different
solutions available.

For some reason, this CGI script that I found on Google displays the
contents of the variable but the HTML surrounding it is displayed
as-is by the browser instead of being rendered:

--
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

import cgi
form = cgi.FieldStorage()

# get a value from the form
value = form.getvalue("dummy")

print "Content-Type: text/plain;charset=utf-8"
print

# print a document
print "You typed: %s" % (
 cgi.escape(value),
 )
--

Here's the output:
--
You typed: test
--

Could this be due to the script itself, or some server configuration?


By using "Content-Type: text/plain", you told the browser to treat it like plain 
text instead of HTML. Use text/html instead.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Dan Sommers
On 2012-08-17 at 15:27:59 +0200,
Regarding "[CGI] Why is HTML not rendered?,"
Gilles  wrote:

> For some reason, this CGI script that I found on Google displays the
> contents of the variable but the HTML surrounding it is displayed
> as-is by the browser instead of being rendered:

... [with all due respect and apologies to another thread on this list!]

> print "Content-Type: text/plain;charset=utf-8"

That line tells the browser that the response is plain text.

Do this instead to have the browser render the HTML:

print "Content-Type: text/html;charset=utf-8"

HTH,
Dan

-- 
Μὴ μοῦ τοὺς κύκλους τάραττε -- Αρχιμηδησ
Do not disturb my circles. -- Archimedes

Dan Sommers, http://www.tombstonezero.net/dan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [CGI] Why is HTML not rendered?

2012-08-17 Thread Rob Day
On 17 August 2012 14:27, Gilles  wrote:

>
> print "Content-Type: text/plain;charset=utf-8"
> print
>


Here's the problem - you're telling the browser to display in plain text.
Try 'text/html' instead.

-- 
Robert K. Day
robert@merton.oxon.org
-- 
http://mail.python.org/mailman/listinfo/python-list


[CGI] Why is HTML not rendered?

2012-08-17 Thread Gilles
Hello

I'm learning how to call Python scripts through the different
solutions available.

For some reason, this CGI script that I found on Google displays the
contents of the variable but the HTML surrounding it is displayed
as-is by the browser instead of being rendered:

--
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

import cgi
form = cgi.FieldStorage()

# get a value from the form
value = form.getvalue("dummy")

print "Content-Type: text/plain;charset=utf-8"
print

# print a document
print "You typed: %s" % (
cgi.escape(value),
)
--

Here's the output:
--
You typed: test
--

Could this be due to the script itself, or some server configuration?

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remote read eval print loop

2012-08-17 Thread Eric Frederich
What I wanted to implement was a debugging console that runs right on the
client rather than on the server.
You'd have to be logged into the application to do anything meaningful or
even start it up.
All of the C functions that I created bindings for respect the security of
the logged in user.

Within the debugging console, after importing all of the bindings, there
would be no reason to import anything whatsoever.
With just the bindings I created and the Python language we could do
meaningful debugging.
So if I block the ability to do any imports and calls to eval I should be
safe right?

On Fri, Aug 17, 2012 at 7:09 AM, rusi  wrote:

> On Aug 17, 12:25 pm, Chris Angelico  wrote:
> > On Fri, Aug 17, 2012 at 12:27 PM, Steven D'Aprano
> >
> >  wrote:
> > > There is already awesome protocols for running Python code remotely
> over
> > > a network. Please do not re-invent the wheel without good reason.
> >
> > > See pyro, twisted, rpyc, rpclib, jpc, and probably many others.
> >
> > But they're all tools for building protocols. I like to make
> > line-based protocols
>
> Dont know if this is relevant.  If it is, its more in the heavyweight
> direction.
> Anyway just saw this book yesterday
>
> http://springpython.webfactional.com/node/39
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread Grant Edwards
On 2012-08-16, Chris Angelico  wrote:
> On Fri, Aug 17, 2012 at 1:40 AM, Ramchandra Apte  
> wrote:
>> On 16 August 2012 21:00, Mark Lawrence  wrote:
>>
>>> and "bottom" reads better than "top"
>>
>> Look you are the only person complaining about top-posting.

That may have been true -- in this thread -- so far.

>> GMail uses top-posting by default. I can't help it if you feel
>> irritated by it.

If you don't care whether or not people read your posts, go ahead and
top-post.  FWIW, you can make up your own private character encoding
and language and post in that if you want.  But, if your goal is to
communicate effectively with others, then proper formatting and
editing is A Good Thing(TM).

> I post using gmail, and I just delete two blank lines at the top and
> go down the bottom to type.
[...]
> And FWIW, I add my voice to those who prefer to read replies
> underneath the original text.

Same here.  I often skip reading top-posted articles entirely, since I
don't really care to take the time to start reading at the bottom,
working my up, trying to figure out exactly what the poster is
replying or referring to in the blob of context-free text at the top.

-- 
Grant Edwards   grant.b.edwardsYow! I guess you guys got
  at   BIG MUSCLES from doing too
  gmail.commuch STUDYING!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANNC] pybotwar-0.8

2012-08-17 Thread Hans Mulder
On 16/08/12 23:34:25, Walter Hurry wrote:
> On Thu, 16 Aug 2012 17:20:29 -0400, Terry Reedy wrote:
> 
>> On 8/16/2012 11:40 AM, Ramchandra Apte wrote:
>>
>>> Look you are the only person complaining about top-posting.
>>
>> No he is not. Recheck all the the responses.
>>
>>> GMail uses top-posting by default.
>>
>> It only works if everyone does it.
>>
>>> I can't help it if you feel irritated by it.
>>
>> Your out-of-context comments are harder to understand. I mostly do not
>> read them.
> 
> It's strange, but I don't even *see* his contributions (I am using a 
> regular newsreader - on comp.lang.python - and I don't have him in the 
> bozo bin). It doesn't sound as though I'm missing much.

I don't see him either.  That is to say: my ISP doesn't have his
posts in comp.lang.python,  The group gmane.comp.python.general
on Gname has them. so if you're really curious, you can point
your NNTP client at news.gmane.org.

> But I'm just curious. Any idea why that would be the case?

Maybe there's some kind of filer in the mail->usenet gateway?

HTH,

-- HansM



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: set and dict iteration

2012-08-17 Thread Ulrich Eckhardt

Am 17.08.2012 03:01, schrieb Paul Rubin:

Ian Kelly  writes:

With regard to key insertion and deletion while iterating over a dict
or set, though, there is just no good reason to be doing that
(especially as the result is very implementation-specific), and I
wouldn't mind a more complete low-level check against it as long as
it's not too expensive (which is not clearly the case with the current
suggestion at all).


One possible approach is to freeze the dictionary against modification
while any iterator is open on it.  You could keep a count of active
iterators in the dict structure, adjusting it whenever an iterator is
created or closed/destroyed.


What if there is an iterator left over from a loop that was terminated 
early? That could block access to the sequence even though nothing is 
/really/ iterating over it.


I personally prefer a reliable error, at least when __debug__ is set. 
Someone suggested a timestamp or a list of active iterators, which both 
sound reasonable. The two should be O(1) and O(#iterators) in complexity 
on all mutating operations and O(1) on iteration, so they should be 
acceptable. With a C implementation it probably boils down to very few 
cycles (checking a pointer/incrementing an integer). I can't say if this 
is feasible without compromising performance though, at the very least 
it requires an additional member in all dicts and iterators.


Uli

--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically determine base classes on instantiation

2012-08-17 Thread Richard Thomas
On Thursday, 16 August 2012 19:49:43 UTC+2, Steven D'Aprano  wrote:
> On Thu, 16 Aug 2012 10:03:51 -0700, Richard Thomas wrote:
> 
> 
> 
> > class Foo(object):
> 
> > def __new__(cls, arg):
> 
> > if isinstance(arg, list):
> 
> > cls = FooList
> 
> > elif isinstance(arg, dict):
> 
> > cls = FooDict
> 
> > return object.__new__(cls, arg)
> 
> > 
> 
> > class FooList(Foo, list):
> 
> > pass
> 
> > 
> 
> > class FooDict(Foo, dict):
> 
> > pass
> 
> 
> 
> 
> 
> Did you actually try your code?
>  

I rarely test code. I'm confident in, however undeserved the confidence. :) In 
this case that's not an error I've ever seen before. Obvious easy fix:

return cls.__new__(cls, arg)

Incidentally when I reply to your posts through the groups.google.com interface 
it inserts a blank quoted line between each pair of lines. My first thought was 
that it was a line endings bug with Google's app but in retrospect that seems 
very likely to have been fixed years ago. Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remote read eval print loop

2012-08-17 Thread rusi
On Aug 17, 12:25 pm, Chris Angelico  wrote:
> On Fri, Aug 17, 2012 at 12:27 PM, Steven D'Aprano
>
>  wrote:
> > There is already awesome protocols for running Python code remotely over
> > a network. Please do not re-invent the wheel without good reason.
>
> > See pyro, twisted, rpyc, rpclib, jpc, and probably many others.
>
> But they're all tools for building protocols. I like to make
> line-based protocols

Dont know if this is relevant.  If it is, its more in the heavyweight
direction.
Anyway just saw this book yesterday

http://springpython.webfactional.com/node/39
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68'

2012-08-17 Thread Peter Otten
nepaul wrote:

> ===case1==:
> import sqlalchemy
> test1 = "631f2f68-8731-4561-889b-88ab1ae7c95a"
> cmdTest1 = "select * from analyseresult where uid = " + test1
> engine =
> 
sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
> c = engine.execute(cmdTest1)
> ==case2===: import
> sqlalchemy test2 = "123"
> cmdTest2 = "select * from analyseresult where uid = " + test2
> engine =
> 
sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
> c = engine.execute(cmdTest1)
> 
> 
> !
> case1 :wrong,(sqlalchemy.exc.ProgrammingError: (ProgrammingError)
> ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68')
> case2:work!

I'd guess the uuid needs to be quoted. Don't do that yourself -- your code 
will become vulnerable to sql injection attacks -- use the dbapi instead:

# Again just guessing; I'm not an sqlalchemy user.
import sqlalchemy 
test1 = "631f2f68-8731-4561-889b-88ab1ae7c95a"
cmdTest1 = "select * from analyseresult where uid = %s"
engine = sqlalchemy.create_engine(
"mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
c = engine.execute(cmdTest1, test1)

Note that I'm not using Python's string formatting. The two arguments are 
passed as is and mysql builds the resulting query.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68'

2012-08-17 Thread Alain Ketterlin
nepaul  writes:

> ===case1==:
> import sqlalchemy 
> test1 = "631f2f68-8731-4561-889b-88ab1ae7c95a"
> cmdTest1 = "select * from analyseresult where uid = " + test1
> engine = 
> sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
> c = engine.execute(cmdTest1)
> ==case2===:
> import sqlalchemy 
> test2 = "123"
> cmdTest2 = "select * from analyseresult where uid = " + test2
> engine = 
> sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
> c = engine.execute(cmdTest1)
>
>
> !
> case1 :wrong,(sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', 
> "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68') case2:work!

Print both cmdTest1 and cmdTest2. Look at them. Are they valid SQL
queries?

-- Alain.
-- 
http://mail.python.org/mailman/listinfo/python-list


sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68'

2012-08-17 Thread nepaul
===case1==:
import sqlalchemy 
test1 = "631f2f68-8731-4561-889b-88ab1ae7c95a"
cmdTest1 = "select * from analyseresult where uid = " + test1
engine = 
sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
c = engine.execute(cmdTest1)
==case2===:
import sqlalchemy 
test2 = "123"
cmdTest2 = "select * from analyseresult where uid = " + test2
engine = 
sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
c = engine.execute(cmdTest1)


!
case1 :wrong,(sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', 
"[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'f2f68') case2:work!
-- 
http://mail.python.org/mailman/listinfo/python-list


python-list@python.org

2012-08-17 Thread Ulrich Eckhardt
I that Outlook & Co are guilty. That and the fact that few people even 
think about this. Even today that makes sense, because it provides an 
exact context. Without that, you wouldn't be able to really understand 
what exactly a person is referring to. Also, it helps people to 
structure their thoughts better.


If the above paragraph doesn't make sense to you, see it interleaved 
below for enlightenment. ;)



Am 17.08.2012 07:19, schrieb Dennis Lee Bieber:

I also tend to blame M$ (Outlook and variants) for this tendency to
quote everything and top-post -- Outlook makes it almost impossible
to do a trim&interleave response style.


I that Outlook & Co are guilty. That and the fact that few people even 
think about this.




Including everything as a trailing quote may be okay in an office
environment, where it serves more as a photocopy included with an paper
mail response. But anyone "raised" on 2400bps dial-up on a service that
charged by the minute (GEnie, Compuserve, et al) rapidly learned to use
as a log-in/pull/log-off/read-reply/log-in/send system, and to remove as
much $$ quoted text as possible.


Even today that makes sense, because it provides an exact context. 
Without that, you wouldn't be able to really understand what exactly a 
person is referring to. Also, it helps people to structure their 
thoughts better.



I tend to disagree with the bandwidth argument, which is obsolete. To 
me, it's more about communication efficiency and it's only one possible 
way to achieve that.


Uli

--
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread Jurko Gospodnetić

  Hi.


As a lurker, I agree completely with Chris's sentiments.


  +1

  Best regards,
Jurko Gospodnetić


--
http://mail.python.org/mailman/listinfo/python-list


Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-17 Thread rusi
On Aug 17, 3:36 am, Chris Angelico  wrote:
> On Fri, Aug 17, 2012 at 1:40 AM, Ramchandra Apte  
> wrote:
> > On 16 August 2012 21:00, Mark Lawrence  wrote:
> >> and "bottom" reads better than "top"
>
> > Look you are the only person complaining about top-posting.
> > GMail uses top-posting by default.
> > I can't help it if you feel irritated by it.
>
> I post using gmail,

If you register on the mailing list as well as google groups, you can
then use googlegroups.
Thereafter appropriately cutting out the unnecessary stuff is easy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remote read eval print loop

2012-08-17 Thread Chris Angelico
On Fri, Aug 17, 2012 at 12:27 PM, Steven D'Aprano
 wrote:
> There is already awesome protocols for running Python code remotely over
> a network. Please do not re-invent the wheel without good reason.
>
> See pyro, twisted, rpyc, rpclib, jpc, and probably many others.

But they're all tools for building protocols. I like to make
line-based protocols that don't need middle-layers, you might like to
use RPC, doesn't matter; either way, neither of us is sending
untrusted code across the internet and executing it.

By all means, use pyro instead of plain sockets to build your
protocol; you still don't need a read/eval/print loop to run across a
network.

Personally, I'm of the opinion that simple text-based protocols are
usually sufficient, and much easier to debug - heavier things like RPC
tend to be overkill. But as Alister pointed out, my main point was not
about the details of how you design your protocol.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list