Python Concurrency, Jan 14-15, Last Chance

2010-01-12 Thread David Beazley

  Python Concurrency Workshop, v2.0
 January 14-15, 2010
  Chicago, Illinois
http://www.dabeaz.com/chicago/concurrent.html

*** Last chance to register.  There are still a few slots available
as well as a deeply discounted student rate. ***

Join David Beazley, author of the Python Essential Reference, for an
in-depth workshop on concurrent programming techniques and
idioms. This workshop, designed for more experienced Python
programmers, covers threads, synchronization, message passing,
multiprocessing, distributed computing, coroutines, asynchronous I/O
and other related topics with an eye towards writing programs that can
run on multiple CPU cores, clusters, or distributed systems.  A major
theme of the workshop is to explore and understand different
programming techniques, their associated performance properties, and
other tradeoffs.  You'll definitely walk away with new insight and a
better understanding of how different parts of Python work under the
covers.

Workshop attendance is strictly limited to six people. More information,
including a detailed topic index, is available at:

http://www.dabeaz.com/chicago/concurrent.html




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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: xml.sax parsing elements with the same name

2010-01-12 Thread Stefan Behnel

amadain, 11.01.2010 20:13:

I have an event log with 100s of thousands of entries with logs of the
form:

event eventTimestamp=2009-12-18T08:22:49.035
uniqueId=1261124569.35725_PFS_1_1340035961
   result value=Blocked/
  filters
  filter code=338 type=Filter_Name
  diagnostic
   result value=Triggered/
  /diagnostic
  /filter
  filter code=338 type=Filter_Name
  diagnostic
   result value=Blocked/
  /diagnostic
  /filter
  /filters
/event

I am using xml.sax to parse the event log.


You should give ElementTree's iterparse() a try (xml.etree package). 
Instead of a stream of simple events, it will give you a stream of 
subtrees, which are a lot easier to work with. You can intercept the event 
stream on each 'event' tag, handle it completely in one obvious code step, 
and then delete any content you are done with to safe memory.


It's also very fast, you will like not loose much performance compared to 
xml.sax.


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


Re: parsing an Excel formula with the re module

2010-01-12 Thread Chris Withers

John Machin wrote:

The xlwt package (of which I am the maintainer) has a lexer and parser
for a largish subset of the syntax ... see  http://pypi.python.org/pypi/xlwt


xlrd, no?

Also worth pointing out that the topic of Python and Excel has its own 
web site:


http://www.python-excel.org

...which links to a more specialist group.

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk

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


Re: Append to an Excel file

2010-01-12 Thread Chris Withers

Niels L. Ellegaard wrote:

pp parul.pande...@gmail.com writes:


On Jan 9, 1:47 am, Jason Scheirer jason.schei...@gmail.com wrote:

On Jan 9, 12:30 am, pp parul.pande...@gmail.com wrote:


Hi All,
How do I add a line to an existing file. This should append to the
existing data in the excel file, which was saved previously.
Thanks,
PP

http://pypi.python.org/pypi/xlwt

Hi Jason and all,

Thanks

I have seen this.. my question is there a  way to append to a excel
file which has been closed. Any specific modes which can be added to
the sheet so that it adds a line to the data which was return in some
earlier running of the program.


I may be wrong, but I think that you have to do the following

1) Use xlrd to read the file. This creates an xlrd.Book
2) Use xlutils to transform the xlrd.Book into a xlwt.WorkBook
3) Edit the xlwt.WorkBook
4) Save the xlwt.WorkBook

https://secure.simplistix.co.uk/svn/xlutils/trunk/xlutils/docs/copy.txt


Yup, that's the one...

Oh to have funded time to turn all the docs for xl(rd|wt|utils) into 
nice Sphinx docs...


Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk

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


Re: unittest inconsistent

2010-01-12 Thread Chris Withers

Phlip wrote:

The reason the 'Tester' object has no attribute 'arg1' is because
self still refers to the object made for testA.


I hope someone else can spot the low-level reason...

...but why aren't you using http://pypi.python.org/pypi/mock/ ? Look
up its patch_object facility...


Indeed, I love mock, although I prefer testfixture replace decorator 
and/or context manager for installing and removing them:


http://packages.python.org/testfixtures/mocking.html

cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk

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


Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach
Argh! This was really annoying! Much time wasted (one naturally thinks that 
silly error must be one's own).


But, anyway:

Lines:

  244  nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
  464  self._nframes = initlength / (self._nchannels * self._sampwidth)

Need to use Python 3.x // integer division.

As a workaround, at least for writing wav-files (I haven't tested reading), one 
may just set the number of frames exactly before writing them.


That should also fix any problems with piping (avoiding file pos seek to patch 
up header).


Also, the unit test should best be improved to check that updating and 
backpatching of number of frames actually works.



PS: It would be nice if someone(TM) could describe here in detail how to 
properly report errors like this. Of course I'm not going to do it if it 
involves establishing Yet Another Account somewhere. But hopefully it doesn't?



Cheers  hth.,

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Terry Reedy

On 1/12/2010 3:25 AM, Alf P. Steinbach wrote:

Argh! This was really annoying! Much time wasted (one naturally thinks
that silly error must be one's own).

But, anyway:

Lines:

244 nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
464 self._nframes = initlength / (self._nchannels * self._sampwidth)

Need to use Python 3.x // integer division.

As a workaround, at least for writing wav-files (I haven't tested
reading), one may just set the number of frames exactly before writing
them.

That should also fix any problems with piping (avoiding file pos seek to
patch up header).

Also, the unit test should best be improved to check that updating and
backpatching of number of frames actually works.


This is a little used module that I did not even recognize. Many of the 
library modules need more tests.



PS: It would be nice if someone(TM) could describe here in detail how to
properly report errors like this. Of course I'm not going to do it if it
involves establishing Yet Another Account somewhere. But hopefully it
doesn't?


Asking about possible bugs here is fine. The above looks like one. One 
can report at bugs.python.org. Yes, registration is needed so that you 
give a name that people can recognize and an email to receive replies 
and questions at. And to discourage spam on the tracker, which sometimes 
slips through anyway when a spam person (rather than machine) bothers to 
register.


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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Chris Withers

Alf P. Steinbach wrote:


PS: It would be nice if someone(TM) could describe here in detail how to 
properly report errors like this. 


http://tinyurl.com/yemcdy7

Of course I'm not going to do it if it 
involves establishing Yet Another Account somewhere. 


Of course that means no-one else will know about the problem, and no-one 
 who can fix this problem will find out about it...


Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Pierre Quentel
On 12 jan, 04:26, Alan Harris-Reid aharrisr...@googlemail.com wrote:
 Hi,

 Does anyone know where I can find any decent dynamically-constructed
 HTML control classes (dropdown list, table, input field, checkbox, etc.)
 written in Python.  For example, for a HTML table I would like something
 like...

 MyTable = html_table()       # instantiate class
 MyTable.data = data_list    # data-list (eg. cursor from SQL SELECT
 statement)
 MyTable.border = 1          
 MyTable.width = 987  
 MyTable.column_headers = col_headers    # list or tuple of column-headers
 table_code = MyTable.table.create()           # returns string
 containing appropriate HTML code

 I don't mind writing my own classes (it will be good practice for me),
 but I don't want to re-invent the wheel if it can be avoided.

 TIA,
 Alan Harris-Reid

Hi,

There are a few modules to generate HTML from Python : there is a list
at http://wiki.python.org/moin/Templating, section HTML Generation
packages

With HTMLTags, your example would be coded like this :

from HTMLTags import *
table = TABLE(border=1,width=987)
table = TR(Sum([TD(header) for header in col_headers]))
for result in data_list:
table = TR(Sum([TD(value) for value in result]))
print table

The operator = means add child in the DOM tree structure, it avoids
having to nest tags with brackets

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


Re: Dynamic HTML controls

2010-01-12 Thread Diez B. Roggisch

Alan Harris-Reid schrieb:


Hi,

Does anyone know where I can find any decent dynamically-constructed 
HTML control classes (dropdown list, table, input field, checkbox, etc.) 
written in Python.  For example, for a HTML table I would like something 
like...


MyTable = html_table()   # instantiate class
MyTable.data = data_list# data-list (eg. cursor from SQL SELECT 
statement)
MyTable.border = 1  MyTable.width = 987  MyTable.column_headers 
= col_headers# list or tuple of column-headers table_code = 
MyTable.table.create()   # returns string containing appropriate 
HTML code


I don't mind writing my own classes (it will be good practice for me), 
but I don't want to re-invent the wheel if it can be avoided.



Maybe toscawidgets is for you, it has a lot of additional features such 
as static dependency declaration  injection.


For a form within a table, it would look like this:


table_form = TableForm(table_form,
   fields=[SingleSelectField(foo, options=[A, 
B, C]), action=/some/action, method=GET)



table_form.render(dict(foo=B))


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


Re: lightweight encryption of text file

2010-01-12 Thread Paul Rubin
John Bokma j...@castleamber.com writes:
 Why EVER make anything yourself when you can buy it?

 Do you make your own processors? Your own hard disk drives?
 Why not?

Well, if you try to make your own processors or hard drives, worst
normal outcome is they don't work and you try something else instead.
This is more like making your own cancer drugs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread Ben Finney
W. eWatson wolftra...@invalid.com writes:

 See my post about the datetime controversy about 3-4 posts up from
 yours.

This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?

-- 
 \ “As we enjoy great advantages from the inventions of others, we |
  `\  should be glad to serve others by any invention of ours; and |
_o__) this we should do freely and generously.” —Benjamin Franklin |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lightweight encryption of text file

2010-01-12 Thread John Bokma
Anthra Norell anthra.nor...@bluewin.ch writes:

 Why EVER make anything yourself when you can buy it?

Do you make your own processors? Your own hard disk drives?
Why not?

-- 
John Bokma

Read my blog: http://johnbokma.com/
Hire me (Perl/Python): http://castleamber.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system function

2010-01-12 Thread Jeremy Sanders
Zabin wrote:

 Thanks for the pointersi had a look around and found the site:
 
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-
us/xcopy.mspx?mfr=true
 
 to disable the prompt- i needed to include /y as below:
  os.system ('xcopy /s %s %s /y ' % (dirExe, dirname_new))
 
 
 and just wondering- whats the drawback of using os.system() command

- It won't work across different platforms (unix, mac, windows)
- Spaces or special characters in the filename will mess up the command line 
and can lead to huge security flaws in your program.
- It's inefficient as you have to start a new program to do the work (slow 
on windows)
- Error handling from the xcopy process will not be easy

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Steve Holden:
 Alf P. Steinbach wrote:
 * W. eWatson:
 Ben Finney wrote:
 W. eWatson wolftra...@invalid.com writes:

 See my post about the datetime controversy about 3-4 posts up from
 yours.
 This forum is distributed, and there's no “up” or “3-4 messages”
 that is
 common for all readers.

 Could you give the Message-ID for that message?

 Sort of like outer space I guess. No real direction. How would I find
 the message ID?
 In Thunderbird (the newsreader that you're using) there's a little '+'
 to the left of the message subject line.

 That shows the headers.

 It shows a very limited subset of the headers ...
 
 Really? My Thunderbird shows all headers. Perhaps you need to configure
 something.

I don't need to configure anything, thank you very much, it's already
configured perfectly nicely as it is, thank you, toView | Headers | Normal.

I agree I can switch to View | Headers | All, but for the typical modern
newsgroup post this reveals a bug in Thunderbird, because the headers
view isn't scrollable: not only can you not see all the headers, but
none of the message is visible either!

 Or do as I wrote next and you snipped, use [View - Message Source].
 
Yup, when I need to see that crap (which is almost never) I just hit
Ctrl/U and look at the headers in the message source.
 
 Cheers  hth. (even if rather off-topic by now, not even direct response!),
 
I've sucked a few eggs in my time. Thanks.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
[...]
 PS: It would be nice if someone(TM) could describe here in detail how to
 properly report errors like this. Of course I'm not going to do it if it
 involves establishing Yet Another Account somewhere. But hopefully it
 doesn't?
 
That's not very public-spirited, is it? Python is open source, remember.
You wouldn't be able to use it if Guido had said you know, I'm just
going to write this language for myself. It's so much trouble building a
development community ...

Give a little something back - create the account, and log the bug. I
promise you'll feel better about yourself ;-)

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Steve Holden
Jeremy wrote:
 Hello all,
 
 I am using re.split to separate some text into logical structures.
 The trouble is that re.split doesn't find everything while re.findall
 does; i.e.:
 
 found = re.findall('^ 1', line, re.MULTILINE)
 len(found)
6439
 tables = re.split('^ 1', line, re.MULTILINE)
 len(tables)
 1
 
 Can someone explain why these two commands are giving different
 results?  I thought I should have the same number of matches (or maybe
 different by 1, but not 6000!)
 
re.MULTLINE is apprently 1, and you are providing it as the maxsplit
argument. Check the API in the documentation.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: problem with multiprocessing and defaultdict

2010-01-12 Thread wiso
Robert Kern wrote:

 On 2010-01-11 17:50 PM, wiso wrote:
 
 The problem now is this:
 start reading file r1_200909.log
 start reading file r1_200910.log
 readen 488832 lines from file r1_200910.log
 readen 517247 lines from file r1_200909.log

 with huge file (the real case) the program freeze. Is there a solution to
 avoid pickling/serialization, ... for example something like this:

 if __name__ == __main__:
  file_names = [r1_200909.log, r1_200910.log]
  pool = multiprocessing.Pool(len(file_names))
  childrens = [Container(f) for f in file_names]
  pool.map(lambda c: c.read(), childrens)

 PicklingError: Can't pickletype 'function': attribute lookup
 __builtin__.function failed
 
 You can't pickle lambda functions.
 
 What information do you actually need back from the workers?
 

They sent back the object filled with data. The problem is very simple: I 
have a container, the container has a method read(file_name) that read a 
huge file and fill the container with datas. I have more then 1 file to read 
so I want to parallelize this process. The reading method is quite slow 
because it involves regex.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Steve Holden
Steve Holden wrote:
[...]
 Can someone explain why these two commands are giving different
 results?  I thought I should have the same number of matches (or maybe
 different by 1, but not 6000!)

 re.MULTLINE is apprently 1, and you are providing it as the maxsplit
 argument. Check the API in the documentation.
 
Sorry, I presume re.MULTILINE must actually be zero for the result of
re,split() to be of length 1 ...

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Web Site Inquiry: Session variable passed in other script

2010-01-12 Thread Steve Holden
webmas...@holdenweb.com wrote:
 The following message was received via the web site.
 
 From:   rahul sharma
 Email:  [see headers]
 Subject:Session variable passed in other script
 Telephone:  
 -
 hello sir
 
 i have some doubt regarding session management in python, i had
 search many times but no useful data found on internet,is there
 any API or function which i used for session,
 
 i want to wrapper class for my script,suppose if i get
 authenticated by useid and password then my result stored in
 session and whenever user execute other script check session of
 the user through session variable result.
 
 what should i do and give me some useful guidence.
 Thanks
 
 
 -
 
You do not give sufficient context for me to give a useful answer, and
in any case your question would be better directed to
python-list@python.org, where it would not rely on the kindness and
availability of a single individual. I have taken the liberty of posting
this reply to that list.

Since you talk about session management I assume you plan to make this
script available on the web? In that case the usual (though not the
only) mechanism for establishing session state is to have the server
issue a cookie with a distinct value to each different client, and then
to associate a specific set of session data with the value submitted by
the client.

If you already know this, then it comes down to the specifics of the web
framework you are using. Since you do not give that information it is
not possible to be more precise.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steve Holden:

Alf P. Steinbach wrote:
[...]

PS: It would be nice if someone(TM) could describe here in detail how to
properly report errors like this. Of course I'm not going to do it if it
involves establishing Yet Another Account somewhere. But hopefully it
doesn't?


That's not very public-spirited, is it? Python is open source, remember.
You wouldn't be able to use it if Guido had said you know, I'm just
going to write this language for myself. It's so much trouble building a
development community ...

Give a little something back - create the account, and log the bug. I
promise you'll feel better about yourself ;-)


You will shortly receive an email to confirm your registration. To complete the 
registration process, visit the link indicated in the email.


Yeah, still waiting...

And I don't feel better. :-(

Oh, mail arriving!

Bah, no, t'was from my travel company.


Cheers,

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


decode(..., errors='ignore') has no effect

2010-01-12 Thread Jens Müller

Hi,

I try to decode a string,e.g.
u'M\xfcnchen, pronounced [\u02c8m\u028fn\xe7\u0259n]'.decode('cp1252', 
'ignore')

but even thoug I use errors='ignore'
I get UnicodeEncodeError: 'charmap' codec can't encode character u'\u02c8' 
in position 21: character maps to undefined


How come?

Thanks,
Jens 


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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Alf P. Steinbach:

* Steve Holden:

Alf P. Steinbach wrote:
[...]

PS: It would be nice if someone(TM) could describe here in detail how to
properly report errors like this. Of course I'm not going to do it if it
involves establishing Yet Another Account somewhere. But hopefully it
doesn't?


That's not very public-spirited, is it? Python is open source, remember.
You wouldn't be able to use it if Guido had said you know, I'm just
going to write this language for myself. It's so much trouble building a
development community ...

Give a little something back - create the account, and log the bug. I
promise you'll feel better about yourself ;-)


You will shortly receive an email to confirm your registration. To 
complete the registration process, visit the link indicated in the email.


Yeah, still waiting...

And I don't feel better. :-(

Oh, mail arriving!

Bah, no, t'was from my travel company.


Hm, similar to Google's feedback forms this, just cul de sac: still no mail!

Trying registration again...

For perhaps I wrote incorrect mail address? No. Correct. Anyway...

Your request is being processed. Please be patient.

Well how f*g darn patient do they expect me to be?

I've decided: I'm not.

Oh sh**, just as I typed the period above the mail finally arrived. It's been, 
let's see,  about 20+ minutes!


And still some miles to go.

Somebody should say THANK YOU for all this effort, pointing out not just the bug 
but exactly what needs fixing, not whining about me not wasting half an hour on 
going through proper channels after already wasting much time on that bug!



- Alf (grumble)
--
http://mail.python.org/mailman/listinfo/python-list


Re: lightweight encryption of text file

2010-01-12 Thread Anthra Norell

Robert Kern wrote:

On 2010-01-11 14:09 PM, Anthra Norell wrote:

Robert Kern wrote:

On 2010-01-09 03:52 AM, Anthra Norell wrote:



Don't use a random generator for encryption purposes! warns the
manual, of which fact I was reminded in no uncertain terms on this 
forum
a few years ago when I proposed the following little routine in 
response

to a post very similar to yours. One critic challenged me to encode my
credit card data and post it. Which I did.


Actually, you just encrypted your credit card number and challenged
comp.lang.python to crack it. No one challenged you to do anything of
the sort. Fortunately, the ever-watchful eye of Google was upon us
that day:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/5fb9ffada975bae9?pli=1 




My dear Robert. Thank you for the clarification. You are right. The
thread recorded by Google doesn't mention the credit card detail. I
remember it distinctly, though. I also remember that it wasn't my idea.
And I recall being urged by another, well-mannered, member of this group
to call it off right away. He wrote--I pretty much quote: ...there must
be a number of machines out there grinding away at your code right now!


You are probably remembering James Stroud's post, but it came in 
response to your challenge.


http://www.opensubscriber.com/message/python-list@python.org/1393006.html


Upon which another critic
conjured up the horror vision of gigahertzes hacking my pathetic 
little
effort to pieces as I was reading his message. Of the well-meaning 
kind,

he urged me to put an immediate stop to this foolishness. I didn't.

No unplanned expenditures ensued.


That's because comp.lang.python is not full of thieves, not because
your algorithm is worth a damn.



You're right about the thieves. You have a point about my algorithm,
although you might express it in a fashion that lives up to its merits.
My algorithm would not resist a brute-force attack that iterates through
all possible keys and analyzes the outcome for non-randomness. I knew
that then and so I posted a second-level encryption, that is, an
encryption of an encryption. Thus the brute-force attack wouldn't find
anything non-random. By not disclosing the detail I may have breached
some formal rule of the craft.


So, you're saying that you lied about the encryption algorithm used in 
your challenge. USENET has no (or very few) formal rules for you to 
breach, but lying certainly isn't ethical behavior. Honestly, it's 
okay to not be a good cryptographer. I'm not. But it is very much not 
okay to be a liar.


I am not a bad cryptographer. I am not a cryptographer. A liar? Your 
judgment is evidence of a commendable broad-mindedness that complements 
computer science with psychology, even ethics, as fields of interest. If 
I may suggest, take your fields of interest other than computer science 
to the more responsive audiences of respective interest groups. You may 
try www.justrage.com for a starter. Also find some reference reading at 
http://www.cnn.com/2008/TECH/11/03/angry.internet/index.html and at 
http://www.recovery-man.com/abusive/rage_vs_anger.htm. On my part I 
would offer you this quote by...I forget whom: You can't sling mud 
without soiling yourself. And if you sling at someone out of range, 
you're the only one getting dirty.
 Isn't it unfortunate that Robert Kern the ethicist takes the stage 
with a contribution totally irrelevant on this forum, let alone to the 
OP's question, and thus crowds out Robert Kern the cryptographer who 
could comment on a much more relevant matter, namely my--possibly rash, 
so what?--conjecture that any brute-force key-guessing attack can be 
foiled by stacking a number of encryptions sufficient to keep the 
fastest super computer busy until the sun goes out five billion years 
from now. It doesn't take all that many. The way I understand it the 
encoding time, the keyed decoding time and the size of the key data grow 
linearly with the number of encryption levels, whereas the 
brute-force-decoding time grows exponentially. Right?
 I finally would point out that my proposals have always been 
attempts to solve the posted problem, no less, no more. I therefore 
consider any criticism to miss the point if it judges the proposal by 
criteria that transcend the posted problem. You'll recall that the 
problem is now, and was then, a simple encryption scheme for private 
use. Private use excludes malicious attacks and so immunity against them 
is not an applicable quality criterion.


Regards

Frederic

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Stefan Behnel

Alf P. Steinbach, 12.01.2010 12:51:

Well how f*g darn patient do they expect me to be?

I've decided: I'm not.

Oh sh**, just as I typed the period above the mail finally arrived. It's 
been, let's see,  about 20+ minutes!


And still some miles to go.

Somebody should say THANK YOU for all this effort, pointing out not just 
the bug but exactly what needs fixing, not whining about me not wasting 
half an hour on going through proper channels after already wasting much 
time on that bug!


Maybe you should just stop using the module. Writing the code yourself is 
certainly going to be faster than reporting that bug, don't you think?


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


Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Peter Otten
Jens Müller wrote:

 I try to decode a string,e.g.
 u'M\xfcnchen, pronounced [\u02c8m\u028fn\xe7\u0259n]'.decode('cp1252',
 'ignore')
 but even thoug I use errors='ignore'
 I get UnicodeEncodeError: 'charmap' codec can't encode character u'\u02c8'
 in position 21: character maps to undefined
 
 How come?

To convert unicode into str you have to *encode()* it.

udecode(...) will implicitly convert to ASCII first, i. e. is 
equivalent to

uencode(ascii).decode(...)

Hence the error message

...codec can't encode character u'\u02c8'...

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Stefan Behnel:

Alf P. Steinbach, 12.01.2010 12:51:

Well how f*g darn patient do they expect me to be?

I've decided: I'm not.

Oh sh**, just as I typed the period above the mail finally arrived. 
It's been, let's see,  about 20+ minutes!


And still some miles to go.

Somebody should say THANK YOU for all this effort, pointing out not 
just the bug but exactly what needs fixing, not whining about me not 
wasting half an hour on going through proper channels after already 
wasting much time on that bug!


Maybe you should just stop using the module. Writing the code yourself 
is certainly going to be faster than reporting that bug, don't you think?


It's part of the standard Python distribution.

Don't you think bugs in the standard library should be fixed?

Anyways, is there any alternative for wave output in Windows except writing the 
thing from scratch?



Cheers,

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


Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Ulrich Eckhardt
Jens Müller wrote:
 I try to decode a string,e.g.
 u'M\xfcnchen, pronounced [\u02c8m\u028fn\xe7\u0259n]'.decode('cp1252',
 'ignore')
 but even thoug I use errors='ignore'
 I get UnicodeEncodeError: 'charmap' codec can't encode character u'\u02c8'
 in position 21: character maps to undefined
 
 How come?

Wrong way? Don't you want to encode the Unicode string using codepage 1252
instead?

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: problem with multiprocessing and defaultdict

2010-01-12 Thread Wolodja Wentland
On Tue, Jan 12, 2010 at 11:48 +0100, wiso wrote:
 They sent back the object filled with data. The problem is very simple: I 
 have a container, the container has a method read(file_name) that read a 
 huge file and fill the container with datas. I have more then 1 file to read 
 so I want to parallelize this process. The reading method is quite slow 
 because it involves regex.

Take a look at multiprocessing.Manager and use one to proxy access to a
*shared* container to your container from all processes.

If your container is a dict it is as easy as:

manager = multiprocessing.Manager()
managed_dict = manager.dict()
...

-- 
  .''`. Wolodja Wentlandwentl...@cl.uni-heidelberg.de 
 : :'  :
 `. `'` 4096R/CAF14EFC 
   `-   081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Stefan Behnel

Alf P. Steinbach, 12.01.2010 13:10:

* Stefan Behnel:
Maybe you should just stop using the module. Writing the code yourself 
is certainly going to be faster than reporting that bug, don't you think?


It's part of the standard Python distribution.

Don't you think bugs in the standard library should be fixed?


Sure. I was just emphasizing the fact that it might be a larger 
contribution to write such a module in the first place than to fix a bug in 
it. The mere fact that the existing module seems valuable enough for you to 
want to use it suggests that the effort that you are putting into getting 
your bug fixed in the mainline distribution is worth it.


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


Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Jens Müller

To convert unicode into str you have to *encode()* it.

udecode(...) will implicitly convert to ASCII first, i. e. is
equivalent to

uencode(ascii).decode(...)

Hence the error message


Ah - yes of course.

And how can you use the system's default encoding with errors=ignore?
The default encoding is the one that is used if no parameters are given to 
encode.


Thanks again!

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


Re: parsing an Excel formula with the re module

2010-01-12 Thread John Machin

On 12/01/2010 6:26 PM, Chris Withers wrote:

John Machin wrote:

The xlwt package (of which I am the maintainer) has a lexer and parser
for a largish subset of the syntax ... see  
http://pypi.python.org/pypi/xlwt


xlrd, no?


A facility in xlrd to decompile Excel formula bytecode into a text 
formula is currently *under discussion*.


The OP was planning to dig the formula text out using COM then parse the 
formula text looking for cell references and appeared to have a rather 
simplistic view of the ease of parsing Excel formula text -- that's why 
I pointed him at those facilities (existing, released, proven in the 
field) in xlwt.




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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steven D'Aprano
On Tue, 12 Jan 2010 12:51:06 +0100, Alf P. Steinbach wrote:

 Oh sh**, just as I typed the period above the mail finally arrived. It's
 been, let's see,  about 20+ minutes!

Aren't you a little old to be suffering from the every decreasing 
attention spans of the MTV generation? Email is not guaranteed to be 
delivered at all, let alone instantly, and can on occasion be delayed by 
days. A twenty minute delay is nothing to get cranky about.

Perhaps you should check the email headers to see where the delay was. 
You're not using grey-listing by any chance are you?


 Somebody should say THANK YOU for all this effort, pointing out not
 just the bug but exactly what needs fixing, not whining about me not
 wasting half an hour on going through proper channels after already
 wasting much time on that bug!

You know the licence fees that you didn't pay for Python?

You know the thousands of dollars in yearly maintenance fees from the 
vendor you didn't pay?

If you *had* paid them, do you think you'd be receiving any better 
service? In my experience, I'd say that your ability to report bugs, let 
alone patches that fix those bugs, would be even less with most 
proprietary software. 

So, with the greatest respect, and with a sense of sympathy for the 
frustration you're feeling (as we all have, at times), I'd like to 
suggest you stop your belly-aching and accept that even the best 
libraries sometimes have bugs in them. You should be thankful that the 
least you have had to pay is a few minutes to report a bug and 20 minutes 
waiting for a confirmation email.

But in any case, even though I don't have any need for the module in 
question, I'd like to thank you for taking the time to write a patch and 
submit it. Without contributions like that, open source software would be 
unable to thrive as it does.



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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Stefan Behnel:

Alf P. Steinbach, 12.01.2010 13:10:

* Stefan Behnel:
Maybe you should just stop using the module. Writing the code 
yourself is certainly going to be faster than reporting that bug, 
don't you think?


It's part of the standard Python distribution.

Don't you think bugs in the standard library should be fixed?


Sure. I was just emphasizing the fact that it might be a larger 
contribution to write such a module in the first place than to fix a bug 
in it.


I'm not interested in credits.

But regarding contributions to the programming community I've done my share, 
including writings and moderating [comp.lang.c++.moderated]. I do not feel I've 
done too little and I almost take offense at that suggestion.



The mere fact that the existing module seems valuable enough for 
you to want to use it suggests that the effort that you are putting into 
getting your bug fixed in the mainline distribution is worth it.


Well, this is for my Python (actually, beginning programmer) writings, at

  http://tinyurl.com/programmingbookP3

(I hope I spelled that right), which is why it has to use standard library 
functionality only, and why implementing the thing from scratch is not an option 
 --  otherwise, if this was something I needed, I'd probably do that.


It's just to have a concrete real world example of modular arithmetic and two's 
complement representation.


The example code looks like this, so far  --  might of course be of help to 
others :-)



code file=simple_wave.py
Lets you generate simple mono (single-channel) [.wav] files.
import wave
import array
import math

default_sample_rate = 44100 # Usual CD quality.

def sample_square( freq, t ):
linear = freq*t % 1.0
if linear  0.5:
return -1.0
else:
return 1.0

def sample_sawtooth( freq, t ):
linear = freq*t % 1.0
if linear  0.5:
return 4.0*linear - 1.0
else:
return 3.0 - 4.0*linear

def sample_sine( freq, t ):
return math.sin( 2*math.pi*freq*t )

def _append_int_to( a, i ):
if i  0:
i = i + 65536
assert( 0 = i  65536 )
a.append( i % 256 )
a.append( i // 256 )

class Writer:
Writes samples to a specified [.wav] file
def __init__( self, filename, sample_rate = default_sample_rate ):
self._sample_rate = sample_rate
self._writer = wave.open( filename, w )
self._writer.setnchannels( 1 )
self._writer.setsampwidth( 2 )  # 2 bytes = 16 bits
self._writer.setframerate( sample_rate )
self._samples = []

def sample_rate( self ):
return self._sample_rate

def write( self, normalized_sample ):
assert( -1 = normalized_sample = +1 )
self._samples.append( normalized_sample )

def close( self ):
data = array.array( B )   # B - unsigned bytes.
for sample in self._samples:
level = round( 32767*sample )
_append_int_to( data, level )
self._writer.setnframes( len( self._samples ) )
self._writer.writeframes( data )
self._writer.close()
/code


code file=ringtone.py
import simple_wave

sample_rate = simple_wave.default_sample_rate
total_time  = 2
n_samples   = sample_rate*total_time

writer = simple_wave.Writer( test.wav )
for i in range( n_samples ):
t = i/sample_rate
samples = (
simple_wave.sample_sine( 440, t ),
simple_wave.sample_sawtooth( (3/2)*440, t ),
)
sample = sum( samples )/len( samples )
writer.write( sample )
writer.close()
/code


Cheers  hth.,

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


Re: Dynamic HTML controls

2010-01-12 Thread Alan Harris-Reid

alex23 wrote:

On Jan 12, 1:26 pm, Alan Harris-Reid aharrisr...@googlemail.com
wrote:
  

Does anyone know where I can find any decent dynamically-constructed
HTML control classes (dropdown list, table, input field, checkbox, etc.)
written in Python.



There's pyWeb[1], which seems pretty close to what you're asking for:

  mytable =able(align='center', cellspacing=0, cellpadding=3,
border=
  mytable.add(tr(td(first row), td(second row)))

While it might be a little heavier than what you're after, you should
also be able to do this with ToscaWidgets[2]. You'd probably have to
make basic widgets for the general HTML controls, but that would give
you a good head-start on writing your own, more complex widgets.
Widgets can be a compilation of Python, HTML, CSS  JS. (I used this
fairly extensively when it used to be called TurboWidgets)

If you want to roll your own from scratch, I'm a big fan of the html
[3] library:

   from html import HTML
   h =TML()
   with h.table(border=', width='987'):
  ...   with h.tr:
  ... for header in ['column 1', 'column 2']:
  ...   h.th(header)
  ...
   print h
  table width=87 border=1
  trthcolumn 1/ththcolumn 2/th/tr
  /table

1: http://www.freenet.org.nz/python/pyweb
2: http://toscawidgets.org
3: http://pypi.python.org/pypi/html/1.7

Hi Alex (I'm assuming that is your name from your nickname)

Thanks for the reply - I'll check-out all 3 solutions you suggest and 
I'm sure I'll find something near to what I am looking for.


Regards,
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Daniel Fetchinson
 PS: It would be nice if someone(TM) could describe here in detail how to
 properly report errors like this. Of course I'm not going to do it if it
 involves establishing Yet Another Account somewhere. But hopefully it
 doesn't?

 That's not very public-spirited, is it? Python is open source, remember.
 You wouldn't be able to use it if Guido had said you know, I'm just
 going to write this language for myself. It's so much trouble building a
 development community ...

 Give a little something back - create the account, and log the bug. I
 promise you'll feel better about yourself ;-)

 You will shortly receive an email to confirm your registration. To
 complete the registration process, visit the link indicated in the email.

 Yeah, still waiting...

 And I don't feel better. :-(

 Oh, mail arriving!

 Bah, no, t'was from my travel company.

 Hm, similar to Google's feedback forms this, just cul de sac: still no mail!

 Trying registration again...

 For perhaps I wrote incorrect mail address? No. Correct. Anyway...

 Your request is being processed. Please be patient.

 Well how f*g darn patient do they expect me to be?

 I've decided: I'm not.

 Oh sh**, just as I typed the period above the mail finally arrived. It's
 been,
 let's see,  about 20+ minutes!

 And still some miles to go.

 Somebody should say THANK YOU for all this effort, pointing out not just the
 bug
 but exactly what needs fixing, not whining about me not wasting half an hour
 on
 going through proper channels after already wasting much time on that bug!

Thanks to this 100% true statement from Brett Cannon there is an easy
way to get rid of your disappointment:



If you are doing open source for anything other than altruistic
reasons you are bound to be disappointed.


HTH,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Lie Ryan
On 01/12/10 23:50, Jens Müller wrote:
 To convert unicode into str you have to *encode()* it.

 udecode(...) will implicitly convert to ASCII first, i. e. is
 equivalent to

 uencode(ascii).decode(...)

 Hence the error message
 
 Ah - yes of course.
 
 And how can you use the system's default encoding with errors=ignore?
 The default encoding is the one that is used if no parameters are given
 to encode.
 
 Thanks again!


 import sys
 sys.getdefaultencoding()
'ascii'
 u'M\xfcnchen, pronounced
[\u02c8m\u028fn\xe7\u0259n]'.encode(sys.getdefaultencoding(), 'ignore')
'Mnchen, pronounced [mnn]'


unless this is for debugging, I doubt ignoring error in this particular
case is an acceptable solution (how do you pronounce [mnn]?)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread Martin P. Hellwig

W. eWatson wrote:
cut

  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.


If timezones might be a problem area, than it might be worth while to 
see it in the context of the actual application. For local, one user 
only, use, the problem will be practically non-existent. Multiple users 
across multiple machines will make it more difficult since you need a 
verified source for each users timezone. But then again what about 
travellers, wrongly set-up machines (right time wrong zone, wrong time 
right zone and wrong zone with wrong time?) or people who just prefer to 
do have their time set to UTC regardless of their location and season 
(when I travelled alot, I just set my wristwatch, phone and laptop to UTC).


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Is python not good enough?

2010-01-12 Thread ikuta liu
I'm a little confused.
Is python not good enough?
for google, enhance python performance is the good way better then
choose build Go language?

Go language try to merge low level, hight level and browser language.

Those I'd like to see it on python..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python not good enough?

2010-01-12 Thread Stefan Behnel

ikuta liu, 12.01.2010 16:09:

I'm a little confused.
Is python not good enough?
for google, enhance python performance is the good way better then
choose build Go language?

Go language try to merge low level, hight level and browser language.

Those I'd like to see it on python..


I think everyone's free to put resources into the creation of new 
programming languages. Google has enough money to put it into all sorts of 
things without the need to have them pay off.


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


Re: Is python not good enough?

2010-01-12 Thread Krister Svanlund
Every language has it uses and Google obviously thought that it would
take more resources to get Python to the level they need it than to
start using Go.

Python is great for alot of things but it's not perfect for anything.

On Tue, Jan 12, 2010 at 4:09 PM, ikuta liu ikut...@gmail.com wrote:
 I'm a little confused.
 Is python not good enough?
 for google, enhance python performance is the good way better then
 choose build Go language?

 Go language try to merge low level, hight level and browser language.

 Those I'd like to see it on python..
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread André
On Jan 12, 9:33 am, Alf P. Steinbach al...@start.no wrote:


 Well, this is for my Python (actually, beginning programmer) writings, at

    http://tinyurl.com/programmingbookP3


Thanks for writing this book.  I just had a quick look at the
beginning of it where you write:
===
As of this writing two main variants of the Python language are in
use, namely
Python 2.x and Python 3.x (versions 3.0 and greater). Mostly they’re
the same but the
effect of e.g. the / division operator changed in 3.0, so in practice
it’s hopeless to try
to create programs that work the same – or even just work – with both
variants.
===
Notwithstanding your experience (finding a bug in wave.py), this
statement is false.  There are plenty of non-trivial applications that
have been ported so that they work as is with both Python 2.x and
Python 3.x.   If you do a google search, I am sure that you can find
many examples proving this point.  For example, you may want to read:
http://mail.mems-exchange.org/durusmail/qp/441/  or try out
Crunchy  (http://code.google.com/p/crunchy).   It may be required to
isolate some small parts and do conditional imports ... but this is
fairly straightforward to do if one writes a new application.

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


Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Peter Otten
Lie Ryan wrote:

 On 01/12/10 23:50, Jens Müller wrote:
 To convert unicode into str you have to *encode()* it.

 udecode(...) will implicitly convert to ASCII first, i. e. is
 equivalent to

 uencode(ascii).decode(...)

 Hence the error message
 
 Ah - yes of course.
 
 And how can you use the system's default encoding with errors=ignore?
 The default encoding is the one that is used if no parameters are given
 to encode.
 
 Thanks again!
 
 
 import sys
 sys.getdefaultencoding()
 'ascii'
 u'M\xfcnchen, pronounced
 [\u02c8m\u028fn\xe7\u0259n]'.encode(sys.getdefaultencoding(), 'ignore')
 'Mnchen, pronounced [mnn]'
 
 
 unless this is for debugging, I doubt ignoring error in this particular
 case is an acceptable solution (how do you pronounce [mnn]?)

Also, I think on most systems

 sys.getdefaultencoding()
'ascii'

You might try

 locale.getpreferredencoding()
'UTF-8'

instead.

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


Re: lightweight encryption of text file

2010-01-12 Thread Robert Kern

On 2010-01-12 05:59 AM, Anthra Norell wrote:

Robert Kern wrote:

On 2010-01-11 14:09 PM, Anthra Norell wrote:

Robert Kern wrote:

On 2010-01-09 03:52 AM, Anthra Norell wrote:



Upon which another critic
conjured up the horror vision of gigahertzes hacking my pathetic
little
effort to pieces as I was reading his message. Of the well-meaning
kind,
he urged me to put an immediate stop to this foolishness. I didn't.

No unplanned expenditures ensued.


That's because comp.lang.python is not full of thieves, not because
your algorithm is worth a damn.



You're right about the thieves. You have a point about my algorithm,
although you might express it in a fashion that lives up to its merits.
My algorithm would not resist a brute-force attack that iterates through
all possible keys and analyzes the outcome for non-randomness. I knew
that then and so I posted a second-level encryption, that is, an
encryption of an encryption. Thus the brute-force attack wouldn't find
anything non-random. By not disclosing the detail I may have breached
some formal rule of the craft.


So, you're saying that you lied about the encryption algorithm used in
your challenge. USENET has no (or very few) formal rules for you to
breach, but lying certainly isn't ethical behavior. Honestly, it's
okay to not be a good cryptographer. I'm not. But it is very much not
okay to be a liar.


I am not a bad cryptographer. I am not a cryptographer. A liar? Your
judgment is evidence of a commendable broad-mindedness that complements
computer science with psychology, even ethics, as fields of interest.


Yes, being ethical is an interest of mine. It should be yours, too.


Isn't it unfortunate that Robert Kern the ethicist takes the stage with
a contribution totally irrelevant on this forum, let alone to the OP's
question, and thus crowds out Robert Kern the cryptographer who could
comment on a much more relevant matter, namely my--possibly rash, so
what?--conjecture that any brute-force key-guessing attack can be foiled
by stacking a number of encryptions sufficient to keep the fastest super
computer busy until the sun goes out five billion years from now. It
doesn't take all that many. The way I understand it the encoding time,
the keyed decoding time and the size of the key data grow linearly with
the number of encryption levels, whereas the brute-force-decoding time
grows exponentially. Right?


This is uncontroversial. It is one reason why the DES algorithm was repeated 
thrice to make the algorithm 3DES. However, it is not especially relevant. The 
point is that you are claiming this group's nonresponse to your challenge as 
evidence that it is strong. What's more, it turns out that you lied about the 
algorithm you used in the challenge. That undermines your claim drastically. 
Since your claim is targeted at convincing the OP to choose your algorithm over 
other choices that are better in every way, refuting your claim is necessarily 
on-topic. I didn't want to discredit you by calling you a liar, but you exposed 
yourself as one.


However, brute force key searching isn't why we think your algorithm is weak (or 
rather, the low key size from your originally stated algorithm was one reason, 
but it was hardly the most striking reason). You are using a linear random 
number generator in a mode that is susceptible to a number of standard attacks. 
It fails to have a number of properties that are necessary in an encryption 
system. One can break your algorithm with less computation than is necessary for 
brute force search. Repeating the algorithm many times will not increase the 
time necessary to break your repeated algorithm exponentially.


It is important that the OP understands this, and that your claims do not go 
unchallenged.



I finally would point out that my proposals have always been attempts to
solve the posted problem, no less, no more. I therefore consider any
criticism to miss the point if it judges the proposal by criteria that
transcend the posted problem. You'll recall that the problem is now, and
was then, a simple encryption scheme for private use. Private use
excludes malicious attacks and so immunity against them is not an
applicable quality criterion.


Encryption is *always* about preventing malicious attacks. If you had called 
your algorithm a no-security obfuscation algorithm, I wouldn't have much 
problem with it (although a real encryption algorithm like p3.py is also 
strictly better for obfuscation, too). I do have a problem with people claiming 
unbreakable encryption when it has been demonstrated to be false.


Words have meanings, and your words claim far too much. It's possible that you 
do not mean to claim so much, but you would then need to change your language. 
The reason that this is so important is that the OP necessarily cannot give you 
all of the information about his use case in a short post to comp.lang.python. 
How do you know that he won't be subject to malicious attacks? You cannot make 

BaseHTTPServer get_request not called till first request

2010-01-12 Thread Adam Tauno Williams
Looking at http://code.activestate.com/recipes/425210/ and
http://code.activestate.com/recipes/499376/ as examples I've attempted
to create a BaseHTTPServer class that times-out accept() ever X seconds
to check some other work.  This seems to work well, but only once the
HTTPServer object has received its first request.  Up until the first
request get_request() is not invoked and not timeout occurs.

class HTTPServer(BaseHTTPServer.HTTPServer):

def server_bind(self):
BaseHTTPServer.HTTPServer.server_bind(self)
self.socket.settimeout(1)
self._shutdown = False

def get_request(self):
while not self._shutdown:
try:
print ' HTTP worker {0} waiting.'.format(self.pid)
self.log.debug('Waiting for connection...')
s, a = self.socket.accept()
s.settimeout(None)
return (s, a)
except socket.timeout:
/// do other work ///
return None, None

The HTTP worker message is not seen until the server has taken a
request, then it seems to dutifully do the timeout.

-- 
OpenGroupware developer: awill...@whitemice.org
http://whitemiceconsulting.blogspot.com/
OpenGroupare  Cyrus IMAPd documenation @
http://docs.opengroupware.org/Members/whitemice/wmogag/file_view

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


Re: lightweight encryption of text file

2010-01-12 Thread Steve Holden
Robert Kern wrote:
 On 2010-01-12 05:59 AM, Anthra Norell wrote:
[ping, pong, ping, pong]
 If the OP uses a real encryption algorithm, he can rely on the fact that
 he can use the algorithm for large files or for plaintexts that a
 malicious agent might choose even if he did not communicate (or even
 know about!) those needs at the time. He cannot rely on those features
 with your algorithm, but you do not reveal those limitations of your
 algorithm. You simply assumed that the OP could deal with those
 limitations, and that does him a disservice.
 
The fact that much hogwash is spoken about encryption through ignorance
is underlined today by the reactions to reports that a team of German
computer scientists have cracked a message encrypted with RSA using a
768-bit key.

  http://www.out-law.com//default.aspx?page=10659

The general tenor of these ill-informed responses is along the lines of
we will soon have to use biometrics or PINs as an additional layer of
protection. This is baloney, pure and simple. If no cryptographic
weaknesses have been demonstrated in the algorithms then the simple
solution (and one that Moore's Law and the rise of multiprocessor
hardware adequately supports) is to use longer keys. 2,048-bit RSA will
be secure at least for my lifetime, unless startling developments come
along in quantum computing.

Biometric and PIN-based access control systems are demonstrably easier
to break than 768-bit encryption, which has just been done for a single
message in something like two years with the aid of a large number of
computers and a brute-force attack. They can also be subverted, which is
rather more difficult for a cryptosystem with properly-protected private
keys.

Just the same, people continue to make exaggerated claims for crypto
systems that have not been subjected to cryptanalysis. This behavior is
 unlikely to change, so you will probably be happier allowing such
people (who are legion) their delusions.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: os.system function

2010-01-12 Thread r0g
Zabin wrote:
 Hey everyone!
 
 I am a new python programmer. I am trying to get the general file
 functionality with options of save and save as working. These save
 functions save a folder with multiple files. Upon using the os.system
 copy function- if my destination directory has files with similar
 names- i am asked whether i want to replace the files on the command
 prompt.
 
 Is there some way of getting this question into a dialog box?

You'll need to use one of the GUI toolkits for that.

wxPython is my prefered one as its cross platform and it renders with
the OS's native toolkit / look. However, that is quite a big dependency
(10MiB) to be carrying around if all you need is a dialog box so you may
want to look into pythons core GUI library, TKL.

Roger.

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Alf P. Steinbach:
 * Steve Holden:
 Alf P. Steinbach wrote:
 [...]
 PS: It would be nice if someone(TM) could describe here in detail
 how to
 properly report errors like this. Of course I'm not going to do it
 if it
 involves establishing Yet Another Account somewhere. But hopefully it
 doesn't?

 That's not very public-spirited, is it? Python is open source, remember.
 You wouldn't be able to use it if Guido had said you know, I'm just
 going to write this language for myself. It's so much trouble building a
 development community ...

 Give a little something back - create the account, and log the bug. I
 promise you'll feel better about yourself ;-)

 You will shortly receive an email to confirm your registration. To
 complete the registration process, visit the link indicated in the
 email.

 Yeah, still waiting...

 And I don't feel better. :-(

 Oh, mail arriving!

 Bah, no, t'was from my travel company.
 
 Hm, similar to Google's feedback forms this, just cul de sac: still no
 mail!
 
 Trying registration again...
 
 For perhaps I wrote incorrect mail address? No. Correct. Anyway...
 
 Your request is being processed. Please be patient.
 
 Well how f*g darn patient do they expect me to be?
 
 I've decided: I'm not.
 
 Oh sh**, just as I typed the period above the mail finally arrived. It's
 been, let's see,  about 20+ minutes!
 
 And still some miles to go.
 
 Somebody should say THANK YOU for all this effort, pointing out not just
 the bug but exactly what needs fixing, not whining about me not wasting
 half an hour on going through proper channels after already wasting much
 time on that bug!

Well, I can do the first bit.  THANK YOU!

I am, however, confused by your description of all this effort. I am
sorry you had to waste time running up against a bug in Python, but even
(?) Microsoft users have been known to complain about the non-responsive
nature of their vendor, and they have paid support contracts.

I am very grateful, as Chairman of the Python Software Foundation, that
you took the time to push this through to completion. I hope that even
if it took you half an hour (and I suspect you are counting the 20
minutes you spent waiting for an email, during which you should not have
been tied up by the bug reporting process, and could have done some
other task in parallel) I hope you will agree that the language has
saved you hundreds of times that in your career as a Python programmer.

Anyway, since I have doubtless already whined on too long for your
tastes, just let me say that I am interested in making the bug reporting
process *much* easier, especially for casual users. Sadly leaving a web
system open is no longer practical in this day and age, as there are
spambots that will fill up the database with rubbish in no time unless
we take precautions.

If you have any suggestions for improving things (and the same goes for
any other readers) I will be happy to listen to them. I do agree that
the bug tracker is a rather high hurdle for people to have to jump over
just to offer feedback on software faults, but the PSF doesn't have the
resources to man customer service lines and the like, so we do what we
can with web-based automation.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Stefan Behnel:
 Alf P. Steinbach, 12.01.2010 12:51:
 Well how f*g darn patient do they expect me to be?

 I've decided: I'm not.

 Oh sh**, just as I typed the period above the mail finally arrived.
 It's been, let's see,  about 20+ minutes!

 And still some miles to go.

 Somebody should say THANK YOU for all this effort, pointing out not
 just the bug but exactly what needs fixing, not whining about me not
 wasting half an hour on going through proper channels after already
 wasting much time on that bug!

 Maybe you should just stop using the module. Writing the code yourself
 is certainly going to be faster than reporting that bug, don't you think?
 
 It's part of the standard Python distribution.
 
 Don't you think bugs in the standard library should be fixed?
 
 Anyways, is there any alternative for wave output in Windows except
 writing the thing from scratch?

For what it's worth, reporting the bug is the right decision. Had you
gone to the trouble of a rewrite and proposed your new module for the
standard library the first discovery you would have made is that nothing
gets accepted without a commitment of maintenance.

Clearly that would have been too much to accept when you merely wish to
correct a small-ish bug in an already satisfactory module.

Thanks again, and I hope the change gets into 3.2, and also the next 3.1
maintenance release. The only remaining requirement is some developer
time, but that is our scarcest resource.

regards
 Steve

PS: Next time it would have helped to include a URL to the issue.

http://bugs.python.org/issue7681

FYI there is already some feedback in the tracker.
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: force URLencoding script

2010-01-12 Thread João

Someone please?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python not good enough?

2010-01-12 Thread Ethan Furman

[please don't top-post]

Krister Svanlund wrote:

On Tue, Jan 12, 2010 at 4:09 PM, ikuta liu ikut...@gmail.com wrote:

I'm a little confused.
Is python not good enough?
for google, enhance python performance is the good way better then
choose build Go language?

Go language try to merge low level, hight level and browser language.

Those I'd like to see it on python..
--
http://mail.python.org/mailman/listinfo/python-list


 Every language has it uses and Google obviously thought that it would
 take more resources to get Python to the level they need it than to
 start using Go.

 Python is great for alot of things but it's not perfect for anything.


s/anything/everything/

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


Re: Fractional Hours from datetime?

2010-01-12 Thread W. eWatson

Ben Finney wrote:

Alf P. Steinbach al...@start.no writes:


And considering this, and the fact that Google's archive is now the
main Usenet archive, message id's are not that useful, really.


You've demonstrated only that Google is an unreliable Usenet archive.

One doesn't even need to use Usenet, in this case, since
comp.lang.python is a forum distributed both as a Usenet forum and a
mailing-list forum.


Good Clarke quote. (Not present here.)
--
http://mail.python.org/mailman/listinfo/python-list


Python 2.6.4 - Urllib2 - Windows XP - Reading streaming HTTP source kills network card ... (believe it or not)

2010-01-12 Thread Sandy Walsh
This is very odd. Hopefully someone can shed some insight. I've tried 
this with Python 2.5.2 and recently upgraded to 2.6.4 and see the same 
problem.


I'm running on Windows XP sp3. I'm interfacing with an IP camera that 
streamed jpeg frames at 10fps over HTTP.


The format of the stream is:

4 bytes - size of the frame N
N bytes - the jpeg frame

I have the following program to read the data. It works fine for about 
30-40 iterations and then my NIC dies. All connectivity to the outside 
world goes away until I need to reboot. So, first I thought it was a 
driver problem. I've replaced the NIC, tried other drivers, you name it 
... same problem.


I've tried it on another machine and while it doesn't take down the NIC, 
all communications to the camera after a while fail with connection 
reset by peer exception.


The camera attempts to keep sending frame after frame (one every 100ms), 
but I'm only interested in the first frame. After I grab it I kill the 
connection to the camera. There is still data coming in. I assume it's 
in HTTP Chunked format, but have not put Wireshark on it yet. I suspect 
Python doesn't like me killing the connection when there is still data 
coming down ... but why would it take down my NIC too?


The code is very simple:

#-
import urllib2
import struct
import time
import datetime

ip='192.168.1.189'
username='user'
password='password'

password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
top_level_url = http://%s; % ip
password_mgr.add_password(None, top_level_url, username, password)

handler = urllib2.HTTPBasicAuthHandler(password_mgr)

opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)

url = http://%s/user/img_stream0.cgi; % (ip, )

while 1:
response = urllib2.urlopen(url)

size_bytes = response.read(4)
size, = struct.unpack(i, size_bytes)

frame = response.read(size)
response.close()

print Got , datetime.datetime.now()
time.sleep(1)
#-

Which gives the following output:

testpull.py
Got  2010-01-12 15:30:08.125000
Got  2010-01-12 15:30:09.453000
Got  2010-01-12 15:30:10.812000
Got  2010-01-12 15:30:12.156000
Got  2010-01-12 15:30:13.515000
Got  2010-01-12 15:30:14.89
Got  2010-01-12 15:30:16.265000
Got  2010-01-12 15:30:17.625000
Got  2010-01-12 15:30:19.031000
Got  2010-01-12 15:30:20.39
Got  2010-01-12 15:30:21.765000
Got  2010-01-12 15:30:23.093000
Got  2010-01-12 15:30:24.437000
Got  2010-01-12 15:30:25.765000
Got  2010-01-12 15:30:27.109000
Got  2010-01-12 15:30:28.75
Got  2010-01-12 15:30:30.078000
Got  2010-01-12 15:30:31.437000
Got  2010-01-12 15:30:32.781000
Got  2010-01-12 15:30:34.546000
Got  2010-01-12 15:30:35.906000
Got  2010-01-12 15:30:37.25
Got  2010-01-12 15:30:38.609000
Got  2010-01-12 15:30:39.953000
Got  2010-01-12 15:30:41.281000
Got  2010-01-12 15:30:42.578000
Got  2010-01-12 15:30:43.921000
Got  2010-01-12 15:30:45.25
Got  2010-01-12 15:30:46.562000
Got  2010-01-12 15:30:47.89
Got  2010-01-12 15:30:49.265000
Got  2010-01-12 15:30:50.625000
Got  2010-01-12 15:30:51.968000
Got  2010-01-12 15:30:53.328000
Got  2010-01-12 15:30:54.734000
Traceback (most recent call last):
  File C:\dev\5110Snapshot\testpull.py, line 22, in module
response = urllib2.urlopen(url)
  File C:\Python26\lib\urllib2.py, line 124, in urlopen
return _opener.open(url, data, timeout)
  File C:\Python26\lib\urllib2.py, line 389, in open
response = self._open(req, data)
  File C:\Python26\lib\urllib2.py, line 407, in _open
'_open', req)
  File C:\Python26\lib\urllib2.py, line 367, in _call_chain
result = func(*args)
  File C:\Python26\lib\urllib2.py, line 1146, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File C:\Python26\lib\urllib2.py, line 1121, in do_open
raise URLError(err)
urllib2.URLError: urlopen error [Errno 10060] A connection attempt 
failed because the connected party did not properly
respond after a period of time, or established connection failed because 
connected host has failed to respond


At which point all connectivity on the PC is dead.

This is truly bizarre.

Anyone have any insights as to what might be happening. Or is there 
something blatantly wrong with my code?


Help!
-Sandy



attachment: swalsh.vcf-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Malte Dik
I totally second Alf in this regard.

There were times you could report a bug by mail (to Debian e.g.) and it 
worked perfectly (for me, the reporter).

Once I went into the maze of bug reporting software and I almost didn't find 
back to the problem I tried to fix while stumbling upon the to-be-reported 
bug.


My assumption is, that there's a reason why bug reporting software is so 
pain-inducing. It's to make people enjoying fixing bugs, because it might be 
easier compared to reporting them :D


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


Re: force URLencoding script

2010-01-12 Thread r0g
João wrote:
 Someone please?


Haven't seen your original post yet mate, usenet can be flaky like that,
might have been a good idea to quote your original post!

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


Re: force URLencoding script

2010-01-12 Thread João
On Jan 12, 8:05 pm, r0g aioe@technicalbloke.com wrote:
 João wrote:
  Someone please?

 Haven't seen your original post yet mate, usenet can be flaky like that,
 might have been a good idea to quote your original post!

 Roger.

Thanks Roger.

 João wrote:
  Someone please?
  Hi.
  I'm trying to figure out how to force URLencoding in my Python 2.4.3
  environment, receiving data as an input argument but I'm really at a loss
  here.

  What am I doing wrong?

#!/usr/bin/env python

import sys
from urllib import urlencode, urlopen
from urllib2 import Request
import urlparse

destination = sys.argv[1]
msg = sys.argv[2] #Will I have problems with this one if the input is
multiline?

# the browser identifies itself using the User-Agent header
# after creating the Request object, it's possible to pass in a
dictionary of headers
user_agent  =  'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322)' # force the request to be identified as IE
5.5
headers =  {  ’User-Agent’  :  user_agent  }

# force no proxy

authentication = 'UID=22541PW=gdyb21LQTcIANtvYMT7QVQ=='
# force Unicode display format
message = u'M=%s' % msg
dest_number = 'N=%s' % destination
data = authentication + message + dest_number

url = 'http://10.112.28.221:38080/GwHTTPin/sendtext'
print 'Encoded URL:', url

#get full URL adding ? to it, followed by the encoded values
#full_url = url + '?' url_values
#should I force url_values = urllib.urlencode(data) instead?
full_url = urllib2.Request(url, data, headers)

response = urllib2.urlopen(full_url) #.urlopen works transparently
with proxies which do not require authentication

processed = urllib.open(full_url)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6.4 - Urllib2 - Windows XP - Reading streaming HTTP source kills network card ... (believe it or not)

2010-01-12 Thread Sandy Walsh
I've also run this under IronPython 2.6 and, while it takes longer 
(about 5 minutes), I get the same results. And this too takes down the 
NIC on the PC.


It's gotta be something with my PC, so don't sweat it ... time for an 
upgrade I think.


-S

attachment: swalsh.vcf-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6.4 - Urllib2 - Windows XP - Reading streaming HTTP source kills network card ... (believe it or not)

2010-01-12 Thread MRAB

Sandy Walsh wrote:
This is very odd. Hopefully someone can shed some insight. I've tried 
this with Python 2.5.2 and recently upgraded to 2.6.4 and see the same 
problem.


I'm running on Windows XP sp3. I'm interfacing with an IP camera that 
streamed jpeg frames at 10fps over HTTP.


The format of the stream is:

4 bytes - size of the frame N
N bytes - the jpeg frame

I have the following program to read the data. It works fine for about 
30-40 iterations and then my NIC dies. All connectivity to the outside 
world goes away until I need to reboot. So, first I thought it was a 
driver problem. I've replaced the NIC, tried other drivers, you name it 
... same problem.


I've tried it on another machine and while it doesn't take down the NIC, 
all communications to the camera after a while fail with connection 
reset by peer exception.


The camera attempts to keep sending frame after frame (one every 100ms), 
but I'm only interested in the first frame. After I grab it I kill the 
connection to the camera. There is still data coming in. I assume it's 
in HTTP Chunked format, but have not put Wireshark on it yet. I suspect 
Python doesn't like me killing the connection when there is still data 
coming down ... but why would it take down my NIC too?


The code is very simple:

#-
import urllib2
import struct
import time
import datetime

ip='192.168.1.189'
username='user'
password='password'

password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
top_level_url = http://%s; % ip
password_mgr.add_password(None, top_level_url, username, password)

handler = urllib2.HTTPBasicAuthHandler(password_mgr)

opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)

url = http://%s/user/img_stream0.cgi; % (ip, )

while 1:
response = urllib2.urlopen(url)

size_bytes = response.read(4)
size, = struct.unpack(i, size_bytes)

frame = response.read(size)
response.close()

print Got , datetime.datetime.now()
time.sleep(1)
#-

Which gives the following output:

testpull.py
Got  2010-01-12 15:30:08.125000
Got  2010-01-12 15:30:09.453000
Got  2010-01-12 15:30:10.812000
Got  2010-01-12 15:30:12.156000
Got  2010-01-12 15:30:13.515000
Got  2010-01-12 15:30:14.89
Got  2010-01-12 15:30:16.265000
Got  2010-01-12 15:30:17.625000
Got  2010-01-12 15:30:19.031000
Got  2010-01-12 15:30:20.39
Got  2010-01-12 15:30:21.765000
Got  2010-01-12 15:30:23.093000
Got  2010-01-12 15:30:24.437000
Got  2010-01-12 15:30:25.765000
Got  2010-01-12 15:30:27.109000
Got  2010-01-12 15:30:28.75
Got  2010-01-12 15:30:30.078000
Got  2010-01-12 15:30:31.437000
Got  2010-01-12 15:30:32.781000
Got  2010-01-12 15:30:34.546000
Got  2010-01-12 15:30:35.906000
Got  2010-01-12 15:30:37.25
Got  2010-01-12 15:30:38.609000
Got  2010-01-12 15:30:39.953000
Got  2010-01-12 15:30:41.281000
Got  2010-01-12 15:30:42.578000
Got  2010-01-12 15:30:43.921000
Got  2010-01-12 15:30:45.25
Got  2010-01-12 15:30:46.562000
Got  2010-01-12 15:30:47.89
Got  2010-01-12 15:30:49.265000
Got  2010-01-12 15:30:50.625000
Got  2010-01-12 15:30:51.968000
Got  2010-01-12 15:30:53.328000
Got  2010-01-12 15:30:54.734000
Traceback (most recent call last):
  File C:\dev\5110Snapshot\testpull.py, line 22, in module
response = urllib2.urlopen(url)
  File C:\Python26\lib\urllib2.py, line 124, in urlopen
return _opener.open(url, data, timeout)
  File C:\Python26\lib\urllib2.py, line 389, in open
response = self._open(req, data)
  File C:\Python26\lib\urllib2.py, line 407, in _open
'_open', req)
  File C:\Python26\lib\urllib2.py, line 367, in _call_chain
result = func(*args)
  File C:\Python26\lib\urllib2.py, line 1146, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File C:\Python26\lib\urllib2.py, line 1121, in do_open
raise URLError(err)
urllib2.URLError: urlopen error [Errno 10060] A connection attempt 
failed because the connected party did not properly
respond after a period of time, or established connection failed because 
connected host has failed to respond


At which point all connectivity on the PC is dead.

This is truly bizarre.

Anyone have any insights as to what might be happening. Or is there 
something blatantly wrong with my code?


Help!


Have you tried keeping the connection open and just reading and
discarding the frames you don't want?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Michel Claveau - MVP
Hi!

I had write PLUIE, for use DHTML as GUI: 
  http://www.ponx.org/ponx/guie.htm
But it is not a good answer to your problem. Sorry.

Nevertheless, there are several functions  methods 
for generate DHTML objects (and Python keep the
control on each object.

@+
-- 
Michel Claveau 


*** sorry for my bad english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: force URLencoding script

2010-01-12 Thread r0g
João wrote:
 On Jan 12, 8:05 pm, r0g aioe@technicalbloke.com wrote:
 João wrote:
 Someone please?
 Haven't seen your original post yet mate, usenet can be flaky like that,
 might have been a good idea to quote your original post!

 Roger.
 
 Thanks Roger.
 
 João wrote:
 Someone please?
 Hi.
 I'm trying to figure out how to force URLencoding in my Python 2.4.3
 environment, receiving data as an input argument but I'm really at a loss
 here.
 
 What am I doing wrong?


 headers =  {  ’User-Agent’  :  user_agent  }

Those quotes need to be either  or ' i.e.

headers =  {  'User-Agent'  :  user_agent  }


If that doesn't sort it then it would be helpful to see a traceback or,
if it is not crashing, get a description of how it is failing to do what
you expect.

Cheers,

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


remove v1 tag using SOAPPy

2010-01-12 Thread Jennifer
I just wonder if there is anyway to remove v1 tag by using SOAPPy.

ticketInfo = SOAPpy.structType()
ticketInfo._addItem(ns1:mytag, stringType(test))


xsd:v1
ns1:mytagtest/ns1:mytag
xsd:v1


How can I get rid of xsd:v1?

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


Re: Is python not good enough?

2010-01-12 Thread Terry Reedy

On 1/12/2010 10:17 AM, Krister Svanlund wrote:

Every language has it uses and Google obviously thought that it would
take more resources to get Python to the level they need it than to
start using Go.


'Google' does not think.

Go builds on previous works by the main developers. I doubt that they 
even considered trying to upgrade Python and in particular, its 
generators, to accomplish the parallel processing goals. Their goal of 
making Go very fast to compile by machines somewhat conflicts with 
Python's goal of being fast to read by humans.


Terry Jan Reedy

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


install exe in virtualenv --no-site-packages

2010-01-12 Thread Jim Pharis
How do I install an exe in a sandboxed virtualenv that's been setup with no
site packages? The package I'm trying to install is pywin32.

TIA,

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


Re: lightweight encryption of text file

2010-01-12 Thread Anthra Norell

Robert Kern wrote:

On 2010-01-12 05:59 AM, Anthra Norell wrote:

Robert Kern wrote:

On 2010-01-11 14:09 PM, Anthra Norell wrote:

Robert Kern wrote:

On 2010-01-09 03:52 AM, Anthra Norell wrote:



Upon which another critic
conjured up the horror vision of gigahertzes hacking my pathetic
little
effort to pieces as I was reading his message. Of the well-meaning
kind,
he urged me to put an immediate stop to this foolishness. I didn't.

No unplanned expenditures ensued.


That's because comp.lang.python is not full of thieves, not because
your algorithm is worth a damn.



You're right about the thieves. You have a point about my algorithm,
although you might express it in a fashion that lives up to its 
merits.
My algorithm would not resist a brute-force attack that iterates 
through

all possible keys and analyzes the outcome for non-randomness. I knew
that then and so I posted a second-level encryption, that is, an
encryption of an encryption. Thus the brute-force attack wouldn't find
anything non-random. By not disclosing the detail I may have breached
some formal rule of the craft.


So, you're saying that you lied about the encryption algorithm used in
your challenge. USENET has no (or very few) formal rules for you to
breach, but lying certainly isn't ethical behavior. Honestly, it's
okay to not be a good cryptographer. I'm not. But it is very much not
okay to be a liar.


I am not a bad cryptographer. I am not a cryptographer. A liar? Your
judgment is evidence of a commendable broad-mindedness that complements
computer science with psychology, even ethics, as fields of interest.


Yes, being ethical is an interest of mine. It should be yours, too.


Isn't it unfortunate that Robert Kern the ethicist takes the stage with
a contribution totally irrelevant on this forum, let alone to the OP's
question, and thus crowds out Robert Kern the cryptographer who could
comment on a much more relevant matter, namely my--possibly rash, so
what?--conjecture that any brute-force key-guessing attack can be foiled
by stacking a number of encryptions sufficient to keep the fastest super
computer busy until the sun goes out five billion years from now. It
doesn't take all that many. The way I understand it the encoding time,
the keyed decoding time and the size of the key data grow linearly with
the number of encryption levels, whereas the brute-force-decoding time
grows exponentially. Right?


This is uncontroversial. It is one reason why the DES algorithm was 
repeated thrice to make the algorithm 3DES. However, it is not 
especially relevant. The point is that you are claiming this group's 
nonresponse to your challenge as evidence that it is strong. What's 
more, it turns out that you lied about the algorithm you used in the 
challenge. That undermines your claim drastically. Since your claim is 
targeted at convincing the OP to choose your algorithm over other 
choices that are better in every way, refuting your claim is 
necessarily on-topic. I didn't want to discredit you by calling you a 
liar, but you exposed yourself as one.


However, brute force key searching isn't why we think your algorithm 
is weak (or rather, the low key size from your originally stated 
algorithm was one reason, but it was hardly the most striking reason). 
You are using a linear random number generator in a mode that is 
susceptible to a number of standard attacks. It fails to have a number 
of properties that are necessary in an encryption system. One can 
break your algorithm with less computation than is necessary for brute 
force search. Repeating the algorithm many times will not increase the 
time necessary to break your repeated algorithm exponentially.


It is important that the OP understands this, and that your claims do 
not go unchallenged.



I finally would point out that my proposals have always been attempts to
solve the posted problem, no less, no more. I therefore consider any
criticism to miss the point if it judges the proposal by criteria that
transcend the posted problem. You'll recall that the problem is now, and
was then, a simple encryption scheme for private use. Private use
excludes malicious attacks and so immunity against them is not an
applicable quality criterion.


Encryption is *always* about preventing malicious attacks. If you had 
called your algorithm a no-security obfuscation algorithm, I 
wouldn't have much problem with it (although a real encryption 
algorithm like p3.py is also strictly better for obfuscation, too). I 
do have a problem with people claiming unbreakable encryption when 
it has been demonstrated to be false.


Words have meanings, and your words claim far too much. It's possible 
that you do not mean to claim so much, but you would then need to 
change your language. The reason that this is so important is that the 
OP necessarily cannot give you all of the information about his use 
case in a short post to comp.lang.python. How do you know that he 
won't be subject to 

Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* André:

On Jan 12, 9:33 am, Alf P. Steinbach al...@start.no wrote:


Well, this is for my Python (actually, beginning programmer) writings, at

   http://tinyurl.com/programmingbookP3



Thanks for writing this book.  I just had a quick look at the
beginning of it where you write:
===
As of this writing two main variants of the Python language are in
use, namely
Python 2.x and Python 3.x (versions 3.0 and greater). Mostly they’re
the same but the
effect of e.g. the / division operator changed in 3.0, so in practice
it’s hopeless to try
to create programs that work the same – or even just work – with both
variants.
===
Notwithstanding your experience (finding a bug in wave.py), this
statement is false.  There are plenty of non-trivial applications that
have been ported so that they work as is with both Python 2.x and
Python 3.x.


I'm sorry but your conclusion does not follow from the fact that you point out.

It is hopeless, especially for a newbie, to create correct Python 2.x+3.x 
compatible code, except totally trivial stuff of course.


This due most of all to the language differences, but also to the fact that 
there are PLENTY of libraries that haven't yet been ported, like PIL...




  If you do a google search, I am sure that you can find
many examples proving this point.  For example, you may want to read:
http://mail.mems-exchange.org/durusmail/qp/441/  or try out
Crunchy  (http://code.google.com/p/crunchy).   It may be required to
isolate some small parts and do conditional imports ... but this is
fairly straightforward to do if one writes a new application.


If it were straightforward then it wouldn't be darned difficult, would it?`:-)

The problem isn't just writing code that runs with both Python languages.

The problem is writing code that is correct with both languages, which is 
hopeless when e.g. integer division changes underfoot, like / meaning two 
different things depending on the language, print syntax changing, so forth.



Cheers  hth.,

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steve Holden:

Alf P. Steinbach wrote:

* Stefan Behnel:

Alf P. Steinbach, 12.01.2010 12:51:

Well how f*g darn patient do they expect me to be?

I've decided: I'm not.

Oh sh**, just as I typed the period above the mail finally arrived.
It's been, let's see,  about 20+ minutes!

And still some miles to go.

Somebody should say THANK YOU for all this effort, pointing out not
just the bug but exactly what needs fixing, not whining about me not
wasting half an hour on going through proper channels after already
wasting much time on that bug!

Maybe you should just stop using the module. Writing the code yourself
is certainly going to be faster than reporting that bug, don't you think?

It's part of the standard Python distribution.

Don't you think bugs in the standard library should be fixed?

Anyways, is there any alternative for wave output in Windows except
writing the thing from scratch?


For what it's worth, reporting the bug is the right decision. Had you
gone to the trouble of a rewrite and proposed your new module for the
standard library the first discovery you would have made is that nothing
gets accepted without a commitment of maintenance.

Clearly that would have been too much to accept when you merely wish to
correct a small-ish bug in an already satisfactory module.

Thanks again, and I hope the change gets into 3.2, and also the next 3.1
maintenance release. The only remaining requirement is some developer
time, but that is our scarcest resource.

regards
 Steve

PS: Next time it would have helped to include a URL to the issue.

http://bugs.python.org/issue7681

FYI there is already some feedback in the tracker.


Yeah, someone who had the bright idea that maybe there isn't a bug, thinking 
instead that maybe a wrong name in *a comment* might be the culprit  --  of 
all things!


He was probably just trying to be helpful.

But what do you say to someone who tries to help but is really just making a 
mess of things? Obama tackled that nicely when he got Thorbjørned (Thorbjørn 
Jagland applying some heavy pressure to give him the Nobel Peace Price). But I'm 
not Obama...



Cheers,

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


Re: interactive terminal in Ubuntu Linux : libreadline5-dev works only in Python 2.6 not 3.1

2010-01-12 Thread Lee Harr

 And my original problem still there : fouled up keys in interactive
 terminal.

When you first had this problem, was python3 installed from
source, or was it from the Ubuntu repository? 

(ie, did you install using apt-get or synaptic or did you just start
out building from source?)

I have python 3 on Ubuntu 9.10 installed using synaptic and
readline works fine.

If yours was from the repo, it's possible that the problem is not
python, but your terminal emulator. Which terminal program
are you using (xterm, konsole, gnome-terminal, etc)?

  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steve Holden:

Alf P. Steinbach wrote:

If you have any suggestions for improving things (and the same goes for
any other readers) I will be happy to listen to them. I do agree that
the bug tracker is a rather high hurdle for people to have to jump over
just to offer feedback on software faults, but the PSF doesn't have the
resources to man customer service lines and the like, so we do what we
can with web-based automation.


Well, regarding the bug tracker register-an-account process, checking headers of 
a duplicate confirmation mail that arrived even later than what I already 
commented on,



Received: from mr1.start.no (unknown [195.159.73.42])
by mail6.start.no (Postfix) with ESMTP id 54EFE1534F8
for al...@start.no; Tue, 12 Jan 2010 12:56:05 +0100 (CET)
Received: from psf.upfronthosting.co.za (bugs.python.org [88.198.142.26])
by mr1.start.no (Postfix) with ESMTP id B24C92B2035
for al...@start.no; Tue, 12 Jan 2010 12:53:53 +0100 (CET)
Received: from psf.upfronthosting.co.za (localhost [10.0.0.1])
by psf.upfronthosting.co.za (Postfix) with ESMTP id AE98D786B3
for al...@start.no; Tue, 12 Jan 2010 12:25:53 +0100 (CET)


As you can see the mail spent exactly 28 minutes (to the second) whirring about 
within psf.upfronthosting.co.za before being sent on to my ISP, where it used 
about 3 minutes on orienting itself towards my machine.


I think that mail hang-up may be easiest to fix...

Perhaps use other SMTP server (would be easiest solution).

Perhaps change to CAPTCHA instead of mail confirmation.

Other suggestions I have would, I think, require a lot of work. And I'm not sure 
it's worth it. But my experience is that Google scores 0 on bug reporting, not 
even allowing you to report anything, at all; Microsoft scores 8 or so, up from 
1 on my scale (they used to have lead-you-around-in-circles forms leading to 
punch-you-in-the nose server errors etc., like Google now, but worse because you 
were paying for this!, but they totally changed their tune a few years back, now 
really good, *except* for the worst most bloated MS software/malware ever, the 
Microsoft installer, which unfortunately CPython uses, a light-weight installer 
would be much better!); and then the GNU g++ team scores top marks, 10+, because 
I've had a g++ bug reported and fixed within just hours! :-)



Cheers,

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Steve Holden:
[...]
 FYI there is already some feedback in the tracker.
 
 Yeah, someone who had the bright idea that maybe there isn't a bug,
 thinking instead that maybe a wrong name in *a comment* might be the
 culprit  --  of all things!
 
 He was probably just trying to be helpful.
 
 But what do you say to someone who tries to help but is really just
 making a mess of things? Obama tackled that nicely when he got
 Thorbjørned (Thorbjørn Jagland applying some heavy pressure to give him
 the Nobel Peace Price). But I'm not Obama...
 
You do just what I am doing now.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: more efficient?

2010-01-12 Thread Aahz
In article 4b3091b2$0$22916$e4fe5...@news.xs4all.nl,
Irmen de Jong  ir...@-nospam-xs4all.nl wrote:

Personally I'm only using the join-style-concat if I know the number of 
strings is rather large, or unknown. Otherwise I stick with just the 
regular string concatenation or string formattting (with % or format). 
Much more readable.

Generally speaking, I always use join() if I'm iterating and almost never
when not iterating.  The performance-killer is concatenation in a tight
loop.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur.  --Red Adair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steve Holden:

Alf P. Steinbach wrote:

* Steve Holden:

[...]

FYI there is already some feedback in the tracker.

Yeah, someone who had the bright idea that maybe there isn't a bug,
thinking instead that maybe a wrong name in *a comment* might be the
culprit  --  of all things!

He was probably just trying to be helpful.

But what do you say to someone who tries to help but is really just
making a mess of things? Obama tackled that nicely when he got
Thorbjørned (Thorbjørn Jagland applying some heavy pressure to give him
the Nobel Peace Price). But I'm not Obama...


You do just what I am doing now.


No, as I stated, I'm not into politics.


Cheers  hth.,

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


Re: Is python not good enough?

2010-01-12 Thread Aahz
In article 1b42700d-139a-4653-8669-d4ee2fc48...@r5g2000yqb.googlegroups.com,
ikuta liu  ikut...@gmail.com wrote:

Is python not good enough? for google, enhance python performance is
the good way better then choose build Go language?

It is not at all clear that -- despite some comments to the contrary --
the Go developers are intending to compete with Python.  Go seems much
more intended to compete with C++/Java.  If they're successful, we may
eventually see GoPython.  ;-)
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur.  --Red Adair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Steve Holden:
 Alf P. Steinbach wrote:

 If you have any suggestions for improving things (and the same goes for
 any other readers) I will be happy to listen to them. I do agree that
 the bug tracker is a rather high hurdle for people to have to jump over
 just to offer feedback on software faults, but the PSF doesn't have the
 resources to man customer service lines and the like, so we do what we
 can with web-based automation.
 
 Well, regarding the bug tracker register-an-account process, checking
 headers of a duplicate confirmation mail that arrived even later than
 what I already commented on,
 
 
 Received: from mr1.start.no (unknown [195.159.73.42])
 by mail6.start.no (Postfix) with ESMTP id 54EFE1534F8
 for al...@start.no; Tue, 12 Jan 2010 12:56:05 +0100 (CET)
 Received: from psf.upfronthosting.co.za (bugs.python.org [88.198.142.26])
 by mr1.start.no (Postfix) with ESMTP id B24C92B2035
 for al...@start.no; Tue, 12 Jan 2010 12:53:53 +0100 (CET)
 Received: from psf.upfronthosting.co.za (localhost [10.0.0.1])
 by psf.upfronthosting.co.za (Postfix) with ESMTP id AE98D786B3
 for al...@start.no; Tue, 12 Jan 2010 12:25:53 +0100 (CET)
 
 
 As you can see the mail spent exactly 28 minutes (to the second)
 whirring about within psf.upfronthosting.co.za before being sent on to
 my ISP, where it used about 3 minutes on orienting itself towards my
 machine.
 
 I think that mail hang-up may be easiest to fix...
 
Agreed, I have passed that to postmaster at python.org. I am not really
sure why that mail host was involved in the transaction, but then I
don't spend my days handling email servers.

 Perhaps use other SMTP server (would be easiest solution).
 
 Perhaps change to CAPTCHA instead of mail confirmation.
 
That's another possibility, yes.

 Other suggestions I have would, I think, require a lot of work. And I'm
 not sure it's worth it. But my experience is that Google scores 0 on bug
 reporting, not even allowing you to report anything, at all; Microsoft
 scores 8 or so, up from 1 on my scale (they used to have
 lead-you-around-in-circles forms leading to punch-you-in-the nose server
 errors etc., like Google now, but worse because you were paying for
 this!, but they totally changed their tune a few years back, now really
 good, *except* for the worst most bloated MS software/malware ever, the
 Microsoft installer, which unfortunately CPython uses, a light-weight
 installer would be much better!); and then the GNU g++ team scores top
 marks, 10+, because I've had a g++ bug reported and fixed within just
 hours! :-)
 
Thanks again for the comments. Let's hope something changes as a result!

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Python and Tkinter Programming by John Grayson

2010-01-12 Thread Ethan Furman

Greetings!

I am hoping to acquire a book on Python and Tkinter, and found this one. 
 However, it was published in 2000 for Python 1.52...


Can somebody who has this book comment its continued relevance?  Is it 
still useful for Python 2.5 and Tk 8.4?  Is it *very* useful?


Comments appreciated!

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


Undo/Redo in PyQt

2010-01-12 Thread Zabin
Hey!

I am trying to implement the undo and redo facility in pyqt. I have
gone through some sites and was wondering whether iyou always need to
create subclasses and their definitions for the undo/redo action. My
program currently has a single window in which the user enters
information which is used to update a text file as soon as the user
leaves the field- so i essentially need to undo the text in that field
as well as the file. I am puzzled as to how to approach this. Any help
will be much appreciated!

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alex Clifford
2010/1/13 Alf P. Steinbach al...@start.no


 Received: from mr1.start.no (unknown [195.159.73.42])
by mail6.start.no (Postfix) with ESMTP id 54EFE1534F8
for al...@start.no; Tue, 12 Jan 2010 12:56:05 +0100 (CET)
 Received: from psf.upfronthosting.co.za (bugs.python.org [88.198.142.26])
by mr1.start.no (Postfix) with ESMTP id B24C92B2035
for al...@start.no; Tue, 12 Jan 2010 12:53:53 +0100 (CET)
 Received: from psf.upfronthosting.co.za (localhost [10.0.0.1])
by psf.upfronthosting.co.za (Postfix) with ESMTP id AE98D786B3
for al...@start.no; Tue, 12 Jan 2010 12:25:53 +0100 (CET)


 As you can see the mail spent exactly 28 minutes (to the second) whirring
 about within psf.upfronthosting.co.za before being sent on to my ISP,
 where it used about 3 minutes on orienting itself towards my machine.


Are you sure it was psf.upfronthosting.co.za that had trouble sending the
email or was it mr1.start.no that having trouble receiving it?

From the headers you can't tell which server had the delay.
-- 
http://mail.python.org/mailman/listinfo/python-list


Confusion about scan_code in modulefinder.py (in python 2.6)

2010-01-12 Thread Brock Pytlik
I've been working with the modulefinder.py code recently and I've come 
across a bit of code I'm not grasping. In the scan_code function, there 
are the following lines:

   if sys.version_info = (2, 5):
   scanner = self.scan_opcodes_25
   else:
   scanner = self.scan_opcodes
I don't understand their purpose. Why would I be running a version of 
python less than 2.6 and using the 2.6 module? Should this be looking at 
the version of python that was used to compile 'co'?


In my use, I'm subclassing the modulefinder class and adapting the 
scan_code function to do what I need, but I've found I need separate 
classes for (2.4, 2.5) and 2.6 because when running 2.4 or 2.5, the 
above code traces back. (In 2.4 because self.scan_opcodes isn't defined, 
in 2.5 because self.scan_opcodes_25 isn't.)


In the end, I've gotten everything working to my satisfaction, but I'm 
curious about how this module (and those lines in particular) were 
designed to be used. Any insight would be appreciated.


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


Re: Problem with Dynamically unloading a module

2010-01-12 Thread Aahz
In article 78388a7a-b148-499a-8894-34e55721e...@k19g2000pro.googlegroups.com,
lordofcode  ajay@gmail.com wrote:

Thanks you all for your replies ,cleared quiet a few doubts about
importing modules and namespace references .
Currently am going with static importing of all modules. But it may
not be efficient in future as the number of interchangeable modules
that I have to import may run in 30-40's.(Basically this Python code
is part of larger GSM Testing project where each module represents one
model of GSM mobile phone and this number keeps growing). So changing
the design will be a last resort.

Worry when you have 30-40 hundreds of modules.  ;-)  Seriously, it's just
memory; Python's efficient dicts make lots of modules not a problem.

If/when it's time to worry, there are other techniques you can use.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur.  --Red Adair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Different number of matches from re.findall and re.split

2010-01-12 Thread Tim Chase

Steve Holden wrote:

Steve Holden wrote:
[...]

Can someone explain why these two commands are giving different
results?  I thought I should have the same number of matches (or maybe
different by 1, but not 6000!)


re.MULTLINE is apprently 1, and you are providing it as the maxsplit
argument. Check the API in the documentation.


Sorry, I presume re.MULTILINE must actually be zero for the result of
re,split() to be of length 1 ...


Because it's not doing a multiline split and it's anchored at the 
beginning of the line, it only returns one result (there's 
nothing before the start-of-line to return as the left-side of 
the split):


 import re
 re.MULTILINE
8
 s = 
... abc
... def
... abc
... def
 re.split('^', s,  re.MULTILINE)
['\nabc\ndef\nabc\ndef']
 re.split('b', s,  re.MULTILINE)
['\na', 'c\ndef\na', 'c\ndef']
 re.split('b', 'ab'*10,  re.MULTILINE)
['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'abab']


But your original logic is sound...the 3rd argument re.split() is 
maxsplit not flags, and if you want to use flags with 
.split() you have to either specify it within the regexp or by 
compiling the regexp and using the resulting compiled object as 
detailed elsewhere in the thread by MRAB and Duncan.


-tkc



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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Terry Reedy

On 1/12/2010 6:31 PM, Alf P. Steinbach wrote:


Perhaps change to CAPTCHA instead of mail confirmation.


I disagree. The point of mail confirmation is not just to assure that a 
human is registering, but that we have a valid email for responses to be 
sent to. Many issues are filed with inadaquate info (platform, Python 
version, full traceback, adequate code snippet, or whatever). So we need 
to be able to reach a person.


Besides which, automated image recognition + barely paid human captcha 
farms have made letter image increasingly useless. Many are now so 
obscure that *I* usually get them wrong.


If there were to be a 'human verifier' system, it might be better based 
on file-in-the-blank questions about Python.


What might be changed more easily is to accept a report but impound it 
until the confirmation reply. Being able to spit out what one has to say 
while it is still fresh in the mind should make the email wait more 
tolerable. What do you think?



Terry Jan Reedy

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


Re: lightweight encryption of text file

2010-01-12 Thread Ethan Furman

Anthra Norell wrote:

 I consider the encryption unbreakable [...] (from previous thread)


I am not a cryptographer. (from this thread)


Then you shouldn't be making claims about your encryption algorithms.


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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steven D'Aprano
On Tue, 12 Jan 2010 23:47:31 +0100, Alf P. Steinbach wrote:

 PS: Next time it would have helped to include a URL to the issue.
 
 http://bugs.python.org/issue7681
 
 FYI there is already some feedback in the tracker.
 
 Yeah, someone who had the bright idea that maybe there isn't a bug,
 thinking instead that maybe a wrong name in *a comment* might be the
 culprit  --  of all things!
 
 He was probably just trying to be helpful.
 
 But what do you say to someone who tries to help but is really just
 making a mess of things? 

Before pointing out the mote in another person's eye, you should consider 
the enormous beam in yours. You initially reported a completely bogus 
error (NameError: name 'framerate' is not defined) and Brian responded to 
that.

I don't know why you're claiming he was responding to a name that was 
commented out, when you included a traceback clearly showing that the 
line was executed.

If we're supposed to think Brian is really just making a mess of 
things (your words) for responding to incorrect information, what are we 
supposed to think of the person who submitted the incorrect information 
in the first place?

I think you need to chill out and stop treating a simple bug report as a 
personal slight on you.




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


Re: interactive terminal in Ubuntu Linux : libreadline5-dev works only in Python 2.6 not 3.1

2010-01-12 Thread Dave WB3DWE
On Sun, 10 Jan 2010 22:08:20 -0800 (PST), casevh cas...@gmail.com
wrote:

On Jan 10, 8:16 pm, Dave WB3DWE wrote:
 On Sat, 9 Jan 2010 16:48:52 -0800 (PST), casevh cas...@gmail.com
 wrote:

 On Jan 9, 3:10 pm, pdlem...@earthlink.net wrote:
  On Sat, 9 Jan 2010 13:27:07 -0800 (PST), casevh cas...@gmail.com
  wrote:

Are you sure you are using the new version of python3.1 (the one
located in /usr/local/bin/)?

What is the result of which python3.1?

What happens if you run /usr/local/bin/python3.1?

casevh

You're correct : there are now two versions of Python 3 on my machine.

Two weeks ago when I installed the Python-3.1.1 from the tarball somehow
it got called up with python3 .  Thats what I've continued to run and
now has all the errors.

in my usr/local/bin are 
2to3  idle3  pydoc3  python3  python3.1  python3.1-config  and,
in light blue, python3-config

Running   python3.1   solves _most_ of the problems :
It imports the random  time modules and runs most of my modules in
the pycode dir.
The libreadline5-dev works fine and all my issues with the keys are
gone. I'm astonished.

However now my modules that import  msvcrt  will not run.  I use this
for single char keyboard input.  Trying to import msvcrt yields 
InputError : No module named msvcrt
I believe a module using this ran before recompilation.  Furthermore I
can find  msvcrtmodule.c in  /home/dave/python31/Python-3.1.1/PC
and msvcrt.rst in /home/dave/python31/Python-3.1.1/Doc/library
I use this a lot.  Suppose I should now learn curses module.

Thanks for everything Dave WB3DWE  pdlem...@earthlink.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steven D'Aprano
On Tue, 12 Jan 2010 23:42:28 +0100, Alf P. Steinbach wrote:

 * André:
 On Jan 12, 9:33 am, Alf P. Steinbach al...@start.no wrote:
 
 Well, this is for my Python (actually, beginning programmer) writings,
 at

http://tinyurl.com/programmingbookP3


 Thanks for writing this book.  I just had a quick look at the beginning
 of it where you write:
 ===
 As of this writing two main variants of the Python language are in use,
 namely
 Python 2.x and Python 3.x (versions 3.0 and greater). Mostly they’re
 the same but the
 effect of e.g. the / division operator changed in 3.0, so in practice
 it’s hopeless to try
 to create programs that work the same – or even just work – with both
 variants.
 ===
 Notwithstanding your experience (finding a bug in wave.py), this
 statement is false.  There are plenty of non-trivial applications that
 have been ported so that they work as is with both Python 2.x and
 Python 3.x.
 
 I'm sorry but your conclusion does not follow from the fact that you
 point out.
 
 It is hopeless, especially for a newbie, to create correct Python
 2.x+3.x compatible code, except totally trivial stuff of course.

So you allege, but André points out that there are existing, non-trivial 
applications that work unmodified under both Python 2.x and 3.x. For 
example, CherryPy:

http://www.cherrypy.org/wiki/WhatsNewIn32

You're welcome to your own opinion, of course, but not your own reality, 
and the reality is that it is NOT hopeless to write correct Python code 
that operates under both 2.6 and 3.x. It's not hopeless because it's been 
done. You might even be able to target versions older than 2.6 if you 
really work at it, as CherryPy does.

Continuing to assert something which is demonstrably untrue simply means 
you lose credibility among those who are familiar with Python.



 This due most of all to the language differences, but also to the fact
 that there are PLENTY of libraries that haven't yet been ported, like
 PIL...

Right, and if your application requires PIL, then it is impossible, but 
for the countless applications that *don't* require PIL, it makes no 
difference at all.


[...]
 The problem is writing code that is correct with both languages, which
 is hopeless when e.g. integer division changes underfoot, like /
 meaning two different things depending on the language, print syntax
 changing, so forth.

from __future__ import division
from __future__ import print_function
from future_builtins import hex, map  # or whatever


Not even close to hopeless.




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


Re: creating tar file and streaming it over HTTP?

2010-01-12 Thread Gabriel Genellina
En Sat, 09 Jan 2010 10:19:00 -0300, pbienst peter.bienst...@gmail.com  
escribió:



OK, thanks to the feedback from everyone I got the PUT from a client
to the WSGI server working.

I'm now trying to go the other way around: use a tar stream in one of
the functions in the WSGI server in order to send files to the client.
Problem is that the WSGI specs expects an iterator as return value for
streaming, whereas TarFile needs to write to a file obj.

Is there any way I can get these two to work together?


I haven't actually tried it, but aren't you looking for a pipe? (os.pipe()  
+ os.fdopen())


--
Gabriel Genellina

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steven D'Aprano:

On Tue, 12 Jan 2010 23:42:28 +0100, Alf P. Steinbach wrote:


* André:

On Jan 12, 9:33 am, Alf P. Steinbach al...@start.no wrote:


Well, this is for my Python (actually, beginning programmer) writings,
at

   http://tinyurl.com/programmingbookP3



Thanks for writing this book.  I just had a quick look at the beginning
of it where you write:
===
As of this writing two main variants of the Python language are in use,
namely
Python 2.x and Python 3.x (versions 3.0 and greater). Mostly they’re
the same but the
effect of e.g. the / division operator changed in 3.0, so in practice
it’s hopeless to try
to create programs that work the same – or even just work – with both
variants.
===
Notwithstanding your experience (finding a bug in wave.py), this
statement is false.  There are plenty of non-trivial applications that
have been ported so that they work as is with both Python 2.x and
Python 3.x.

I'm sorry but your conclusion does not follow from the fact that you
point out.

It is hopeless, especially for a newbie, to create correct Python
2.x+3.x compatible code, except totally trivial stuff of course.


So you allege, but André points out that there are existing, non-trivial 
applications that work unmodified under both Python 2.x and 3.x. For 
example, CherryPy:


http://www.cherrypy.org/wiki/WhatsNewIn32

You're welcome to your own opinion, of course, but not your own reality, 
and the reality is that it is NOT hopeless to write correct Python code 
that operates under both 2.6 and 3.x. It's not hopeless because it's been 
done. You might even be able to target versions older than 2.6 if you 
really work at it, as CherryPy does.


Continuing to assert something which is demonstrably untrue simply means 
you lose credibility among those who are familiar with Python.


You're confusing the existence of special cases where something has been done, 
at great cost, with a belief that it's practical to do so in general.


It's not exactly like confusing existential versus universal quantification, but 
it's close.


Thus, your demonstration amounts to it's not hopeless to walk on the moon: 
look, Louis Armstrong did!  --  uh, Neil, whatever.


He he. :-)

No, sorry, I apologize, I'm unkind now.

*Slapping my keyboard hand*

But it gets to me how often people here sort of rise to the defense of Python as 
if it needed defending.


It's a great language, it needs no defense, especially not of the kind where one 
tries to suppress facts and silence critique. Indeed, what it needs seems to 
instead be the opposite, a good dose of reality and openness. The reality is 
that the divide between 2.x and 3.x is still very wide, and utterly hopeless for 
a newbie to cross (professionals can do so at great cost).


Over in C++-land it's opposite.

Even the most enhusiastic C++ programmers almost revel in finding faults with 
the language and its standard library, tools etc. And I think that's because 
there's no inferiority complex, or very little of it. So, repeating: Python is a 
great language, it really is, but There Are Issues, of course there are issues, 
and the best way or at least a good way to go about it is adopt that (great, but 
of course has issues) as one's basic view, and be critical.




This due most of all to the language differences, but also to the fact
that there are PLENTY of libraries that haven't yet been ported, like
PIL...


Right, and if your application requires PIL, then it is impossible, but 
for the countless applications that *don't* require PIL, it makes no 
difference at all.


They require other stuff. :-)

Plus, the basic language issues are at the core of all these problems.

But see above.



[...]

The problem is writing code that is correct with both languages, which
is hopeless when e.g. integer division changes underfoot, like /
meaning two different things depending on the language, print syntax
changing, so forth.


from __future__ import division
from __future__ import print_function
from future_builtins import hex, map  # or whatever


Not even close to hopeless.


You might consider that I'm very much aware of the above facilities.

Then be a little critical and think about, what problems could it be that, in 
spite of that to you apparent simplicity, hinders the widespread adoption of 
Python 3.x?


Repeating, Python is a great language. I'm not about dissing the language. I 
think it's rather silly when people believe that, and it's rather sad when they 
then employ negative sum thinking: think positive!


Cheers  hth.,

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


Re: interactive terminal in Ubuntu Linux : libreadline5-dev works only in Python 2.6 not 3.1

2010-01-12 Thread Dave WB3DWE
On Wed, 13 Jan 2010 03:29:05 +0430, Lee Harr miss...@hotmail.com
wrote:
When you first had this problem, was python3 installed from
source, or was it from the Ubuntu repository? 

(ie, did you install using apt-get or synaptic or did you just start
out building from source?)

I have python 3 on Ubuntu 9.10 installed using synaptic and
readline works fine.

If yours was from the repo, it's possible that the problem is not
python, but your terminal emulator. Which terminal program
are you using (xterm, konsole, gnome-terminal, etc)?

Lee ,

Over a month ago I downloaded the tarball Python-3.1.1 from
the python website.  Then the Synaptic Package Manager did not
contain this ( latest ) version. There is already python 2.x on my 
Ubuntu 9.04 ( think its 2.6 ).  Think I saw 3.0 on Synaptic but
not 3.1  Supposedly 3.1 has faster i/o .

I know less about Ubuntu than python. I struggled with Linux for 
several weeks. On Jan 2  I attempted installation ( in dir containing
Python-3.1.1 ) with :
$  ./configure
$  make
$  make test
$  sudo make install

Did not seem to work ( didn't record exactly what happened, perhaps
I didn't put in sudo ), so I ran above again.  Did not use altinstall.

Did not get the tarball with apt-get or from Synaptic.  Just downloaded
it from python site.  The readme gave the build instructions above.

I've exclusively used gnome.  Quite happy with gedit's handling of
python code.

I shouldn't have been greedy and should have settled for 3.0
from Synaptic.

Now I have problems with three versions on my machine.  Please see
my exchanges with casevh for details.

Perhaps the best solution would be to wipe off all 3.1 versions and
simply install 3.0 from Synaptic.

This whole thing with the Python interactive interpreter keys actually
started with my sons, who are Mac enthusiasts. One gave me a MacBook.
Alas the Python interpreter keys were fouled up, as well as it having a
simplified keyboard. Apple took it back, but it was disconcerting when
I found the same key problem in Ubuntu python 3.1  Apple must change
their software as I retried a new MacBook yesterday. To my great
surprise the python 2.6 interpreter worked fine, while on at least two
MacBooks last month it did not.

Thanks for your help, Dave pdlem...@earthlink.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easy Q

2010-01-12 Thread Gabriel Genellina
En Sat, 09 Jan 2010 13:11:28 -0300, Victor Subervi  
victorsube...@gmail.com escribió:



Hi;
I have a string.join statement on a variable that comes from a
cgi.FieldStorage().getlist. The variable may be a list or a single  
value. I
need to treat it differently depending on which it is. How can I  
distinguish

it? len(var) will obviously give me the length of the string if it's a
string and the length of the list if it's a list.


Are you sure you have tested with getlist()?
getlist() *always* returns a list: an empty one, a list containing a  
single item, or many items. getvalue() on the other hand may return None,  
a single item, or a list.


--
Gabriel Genellina

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Steven D'Aprano:

On Tue, 12 Jan 2010 23:47:31 +0100, Alf P. Steinbach wrote:


PS: Next time it would have helped to include a URL to the issue.

http://bugs.python.org/issue7681

FYI there is already some feedback in the tracker.

Yeah, someone who had the bright idea that maybe there isn't a bug,
thinking instead that maybe a wrong name in *a comment* might be the
culprit  --  of all things!

He was probably just trying to be helpful.

But what do you say to someone who tries to help but is really just
making a mess of things? 


Before pointing out the mote in another person's eye, you should consider 
the enormous beam in yours. You initially reported a completely bogus 
error (NameError: name 'framerate' is not defined) and Brian responded to 
that.


I don't know why you're claiming he was responding to a name that was 
commented out, when you included a traceback clearly showing that the 
line was executed.


No, the out-commented line was not executed and was not shown in any traceback.

Comments are not executed.


If we're supposed to think Brian is really just making a mess of 
things (your words) for responding to incorrect information, what are we 
supposed to think of the person who submitted the incorrect information 
in the first place?


I'm sorry but you're trying to make people believe something that you know is 
false, which is commonly called lying.


The error report included the line numbers of the buggy lines, plus a correction 
of the output: I first pasted incorrect error message, then corrected that 
*immediately*. But I just found no way to edit the original message, so both 
that and the correction ended up present. The correction with Sorry, here's the 
correct message, or words to that effect. In the one and only original submission.


So it's not like the person responding should have any problem at all, and it's 
not like he was presented with incorrect information. To top it off he did not 
respond to the output that was corrected. He believed the problem was a name in 
a comment.



I think you need to chill out and stop treating a simple bug report as a 
personal slight on you.


I'm sorry but you're again trying to make people believe something that you know 
is false, which is commonly called lying: it is not the case that I have strong 
feelings or any feelings at all about that bug report or any other.


But you're starting to annoy me.

I think it's OK when you respond to technical issues where you have 
misunderstood something basic, even when you do that by assertion, as you 
usually do (it would be better if you just asked about things that you don't 
understand). But it's not OK when you're trying to create impressions that are 
false, and it's not OK when you try to demonstrate telepathic powers and discuss 
others' emotions and motivations. I tell you straight.



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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Terry Reedy:

On 1/12/2010 6:31 PM, Alf P. Steinbach wrote:


Perhaps change to CAPTCHA instead of mail confirmation.


I disagree. The point of mail confirmation is not just to assure that a 
human is registering, but that we have a valid email for responses to be 
sent to. Many issues are filed with inadaquate info (platform, Python 
version, full traceback, adequate code snippet, or whatever). So we need 
to be able to reach a person.


Besides which, automated image recognition + barely paid human captcha 
farms have made letter image increasingly useless. Many are now so 
obscure that *I* usually get them wrong.


If there were to be a 'human verifier' system, it might be better based 
on file-in-the-blank questions about Python.


What might be changed more easily is to accept a report but impound it 
until the confirmation reply. Being able to spit out what one has to say 
while it is still fresh in the mind should make the email wait more 
tolerable. What do you think?


I think those are all good points. :-)


Cheers,

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


A question about Python versions

2010-01-12 Thread Gib Bogle
I am learning Python, and using PyQt to develop a GUI that will be used to run a 
Fortran program on Windows, Linux and Mac OS X (I think Python is great, btw). 
Without thinking about it I downloaded and started working with a fairly recent 
Python version, 2.5.4.  I've now become aware of the existence of Python 3.1, 
which apparently is a major revision of the language.  Does it make sense to 
stick with Python 2.x at this point, or should I be starting off with 3.1?  If 
it is recommended to stick with version 2, should I use the latest (2.6.4 or 
2.7), and if so why?  Thanks.

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


Re: interactive terminal in Ubuntu Linux : libreadline5-dev works only in Python 2.6 not 3.1

2010-01-12 Thread casevh
On Jan 12, 9:03 pm, Dave WB3DWE wrote:
 On Sun, 10 Jan 2010 22:08:20 -0800 (PST), casevh cas...@gmail.com
 wrote:





 On Jan 10, 8:16 pm, Dave WB3DWE wrote:
  On Sat, 9 Jan 2010 16:48:52 -0800 (PST), casevh cas...@gmail.com
  wrote:

  On Jan 9, 3:10 pm, pdlem...@earthlink.net wrote:
   On Sat, 9 Jan 2010 13:27:07 -0800 (PST), casevh cas...@gmail.com
   wrote:

 Are you sure you are using the new version of python3.1 (the one
 located in /usr/local/bin/)?

 What is the result of which python3.1?

 What happens if you run /usr/local/bin/python3.1?

 casevh

 You're correct : there are now two versions of Python 3 on my machine.

 Two weeks ago when I installed the Python-3.1.1 from the tarball somehow
 it got called up with python3 .  Thats what I've continued to run and
 now has all the errors.

 in my usr/local/bin are
     2to3  idle3  pydoc3  python3  python3.1  python3.1-config  and,
         in light blue, python3-config

 Running   python3.1   solves _most_ of the problems :
     It imports the random  time modules and runs most of my modules in
 the pycode dir.
     The libreadline5-dev works fine and all my issues with the keys are
 gone. I'm astonished.

 However now my modules that import  msvcrt  will not run.  I use this
 for single char keyboard input.  Trying to import msvcrt yields
     InputError : No module named msvcrt
 I believe a module using this ran before recompilation.  Furthermore I
 can find  msvcrtmodule.c in  /home/dave/python31/Python-3.1.1/PC
 and msvcrt.rst in /home/dave/python31/Python-3.1.1/Doc/library
 I use this a lot.  Suppose I should now learn curses module.

 Thanks for everything         Dave WB3DWE      pdlem...@earthlink.net- Hide 
 quoted text -

 - Show quoted text -

msvcrt provides support for the MicroSoft Visual C RunTime so it won't
run on Ubuntu.

The files that you see are the source code and documentation but the
source code is only compiled on Windows.

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


Re: A question about Python versions

2010-01-12 Thread Chris Rebert
On Tue, Jan 12, 2010 at 10:09 PM, Gib Bogle
g.bo...@auckland.no.spam.ac.nz wrote:
 I am learning Python, and using PyQt to develop a GUI that will be used to
 run a Fortran program on Windows, Linux and Mac OS X (I think Python is
 great, btw). Without thinking about it I downloaded and started working with
 a fairly recent Python version, 2.5.4.  I've now become aware of the
 existence of Python 3.1, which apparently is a major revision of the
 language.  Does it make sense to stick with Python 2.x at this point, or
 should I be starting off with 3.1?

This is an FAQ, so you can search the archives for many other
responses. If your program needs to use any third-party libraries
besides PyQt, you should probably use 2.x as most libraries have yet
to be ported to 3.x yet (luckily, PyQt apparently has been ported
already). If your program will be pretty self-sufficient, Python 3 is
definitely an option and will be nicer to use thanks to the
improvements to the language, but most of the changes (aside from
strings becoming Unicode) aren't dramatic; it is clearly still the
same language (unlike Perl 5 - Perl 6).

 If it is recommended to stick with
 version 2, should I use the latest (2.6.4 or 2.7), and if so why?  Thanks.

The latest stable one, 2.6.4 (2.7 is a preview release); there's no
reason not to, and newer versions have more features, bugfixes, etc.
Though you should double-check the compatibility of any libraries
you'll be using of course.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about Python versions

2010-01-12 Thread Sridhar Ratnakumar

On 1/12/2010 10:09 PM, Gib Bogle wrote:

I am learning Python, and using PyQt to develop a GUI that will be used
to run a Fortran program on Windows, Linux and Mac OS X (I think Python
is great, btw). Without thinking about it I downloaded and started
working with a fairly recent Python version, 2.5.4.  I've now become
aware of the existence of Python 3.1, which apparently is a major
revision of the language.  Does it make sense to stick with Python 2.x
at this point, or should I be starting off with 3.1?


Stick with 2.x.


If it is
recommended to stick with version 2, should I use the latest (2.6.4 or
2.7), and if so why?  Thanks.


2.6.4 definitely (as 2.7 final is not released yet).

Also see: http://stackoverflow.com/questions/170921

-srid

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Stefan Behnel

Alf P. Steinbach, 13.01.2010 06:39:

* Steven D'Aprano:

On Tue, 12 Jan 2010 23:42:28 +0100, Alf P. Steinbach wrote:

It is hopeless, especially for a newbie, to create correct Python
2.x+3.x compatible code, except totally trivial stuff of course.


So you allege, but André points out that there are existing, 
non-trivial applications that work unmodified under both Python 2.x 
and 3.x. For example, CherryPy:


http://www.cherrypy.org/wiki/WhatsNewIn32

You're welcome to your own opinion, of course, but not your own 
reality, and the reality is that it is NOT hopeless to write correct 
Python code that operates under both 2.6 and 3.x. It's not hopeless 
because it's been done. You might even be able to target versions 
older than 2.6 if you really work at it, as CherryPy does.


Continuing to assert something which is demonstrably untrue simply 
means you lose credibility among those who are familiar with Python.


You're confusing the existence of special cases where something has been 
done, at great cost, with a belief that it's practical to do so in general.


Unless you can prove that it's *not* practical in general, you will have to 
live with the fact that it was, and continues to be, practical for existing 
code bases (and certainly for new code), so it clearly is not hopeless to 
do so, not even in general.


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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Stefan Behnel


Alf P. Steinbach, 13.01.2010 06:55:

* Steven D'Aprano:
I think you need to chill out and stop treating a simple bug report as 
a personal slight on you.


I'm sorry but you're again trying to make people believe something that 
you know is false, which is commonly called lying: it is not the case 
that I have strong feelings or any feelings at all about that bug report 
or any other.


Then why don't you just stop blaming the world for that terrible doom that 
was laid upon you by running into a bug?




But you're starting to annoy me.


Funny that it's you writing that.

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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Steven D'Aprano
On Wed, 13 Jan 2010 06:39:53 +0100, Alf P. Steinbach wrote:

 Then be a little critical and think about, what problems could it be
 that, in spite of that to you apparent simplicity, hinders the
 widespread adoption of Python 3.x?


(1) Most Linux distributions still come standard with Python 2.5 or 
older, not even 2.6. Consequently, most developers are still writing for 
2.5 or even 2.4 and won't even consider 3.1 until the distros provide it 
as standard. Apple also comes standard with 2.5, and I believe that when 
hardware vendors supply it on Windows systems, it's typically 2.5 also.

(2) Because of the negativity of people overstating the differences 
between 2.x and 3.x.

(3) And because of the slow pace at which major third-party libraries 
have supported 3.x, which is mostly a matter of man-power rather than 
technical difficulty.


It is difficult to support both 2.4 and 2.5, because 2.5 introduces a 
whole lot of excellent features that 2.4 doesn't have. I know, because 
I've tried. (After spending much effort trying to develop my own 
compatibility layer, I eventually decided to just stop supporting 2.4.) 
Do people go on and on and on about how it is hopeless to support 
multiple versions of 2.x? No, of course they don't. It requires extra 
work, and it's inconvenient, but it can be done and it is done.

Trying to support everything from 2.0 to 3.1 would be horrible, but not 
because 3.1 is so different from 2.x. The oldest versions of the 2.x 
series lack so many features that have become fundamental to modern 
Python: no generators, no decorators, no iterators, and others. But 
supporting 2.6 and 3.0/3.1 is nothing as so hard. I would argue that, 
fundamentally, there are fewer differences between 2.6 and 3.1 than 
between 2.1 and 2.5.

Upgrading a major application or library to support 3.x is a big job, 
simply because *any* re-factorising of a major application is a big job. 
But writing a new application supporting 2.6 and 3.x from scratch is a 
much simpler process. Likewise writing small scripts.

To say as you do that the change in the semantics of the division 
operator makes the task hopeless is simply ridiculous. It's a one-line 
fix: from __future__ import division at the top of each module, and you 
now have identical semantics in both 2.6 and 3.x.

Nobody is trying to understate the complexity of writing a large 
application that supports both 2.6 and 3.x, or of taking an existing 
library written for 2.5 and upgrading it to support 3.1. But the 
magnitude of these tasks is no greater (and potentially smaller) than 
supporting (say) 2.3 through 2.5. To describe it as hopeless is simply 
mistaken and weakens your credibility.




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


Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-12 Thread Alf P. Steinbach

* Stefan Behnel:

Alf P. Steinbach, 13.01.2010 06:39:

* Steven D'Aprano:

On Tue, 12 Jan 2010 23:42:28 +0100, Alf P. Steinbach wrote:

It is hopeless, especially for a newbie, to create correct Python
2.x+3.x compatible code, except totally trivial stuff of course.


So you allege, but André points out that there are existing, 
non-trivial applications that work unmodified under both Python 2.x 
and 3.x. For example, CherryPy:


http://www.cherrypy.org/wiki/WhatsNewIn32

You're welcome to your own opinion, of course, but not your own 
reality, and the reality is that it is NOT hopeless to write 
correct Python code that operates under both 2.6 and 3.x. It's not 
hopeless because it's been done. You might even be able to target 
versions older than 2.6 if you really work at it, as CherryPy does.


Continuing to assert something which is demonstrably untrue simply 
means you lose credibility among those who are familiar with Python.


You're confusing the existence of special cases where something has 
been done, at great cost, with a belief that it's practical to do so 
in general.


Unless you can prove that it's *not* practical in general, you will have 
to live with the fact that it was, and continues to be, practical for 
existing code bases (and certainly for new code), so it clearly is not 
hopeless to do so, not even in general.


Simple proof: Python 3.x still lacks widespread usage. :-)


Cheers  hth.,

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


Re: A question about Python versions

2010-01-12 Thread Terry Reedy

On 1/13/2010 1:09 AM, Gib Bogle wrote:

I am learning Python, and using PyQt to develop a GUI that will be used
to run a Fortran program on Windows, Linux and Mac OS X (I think Python
is great, btw). Without thinking about it I downloaded and started
working with a fairly recent Python version, 2.5.4. I've now become
aware of the existence of Python 3.1, which apparently is a major
revision of the language. Does it make sense to stick with Python 2.x at
this point, or should I be starting off with 3.1? If it is recommended
to stick with version 2, should I use the latest (2.6.4 or 2.7), and if
so why? Thanks.


My view is that if PyQt works with 3.1 (I have the impression it does 
but may be wrong) and that is the only 3rd parth library you need, or 
anything else you need works with 3.1, then strongly consider 3.1 for 
new code. The main difference between 2.6 and 3.1 is the number of old, 
obsolete things removed that you will not even be tempted to learn about.


Terry Jan Reedy


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


[issue7679] Warning building 2.7 on OS X 10.6 libintl.h Present But Cannot Be Compiled

2010-01-12 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Works for me.

GNU gettext, which provides libintl, is not included in OS X 10.6.  Chances are 
your build is being contaminated by packages installed via MacPorts or Fink or 
in /usr/local.  If you do want to build with it, check config.log in your build 
directory.  I bet you'll find that it is trying to pick up a 32-bit only 
version from MacPorts or friends.

--
nosy: +ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7679
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >