[ANN] Pida 0.6beta3

2009-09-01 Thread poelzi
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

We are proud to announce the hopfully last beta of Pida 0.6. [1]

It was a long time since beta2 and a lot of changes happened since then:

== Core Highlights ==
• multiprocessing language plugins
Language plugins can now use a multiprocessing infrastructure which
allows expensive operations to be done on other cpu cores. This
increases the speed of plugins like python_lint and python
dramatically and do not make the gui sluggish anymore.
• project file caches
Projects now have a filecache which allows fast queries to filenames
and filetypes. The QuickOpen plugin provides a gui for this,
allowing the user to open files to which parts of the name, path or
filetype are known
• very precise feature selection from LanguagePlugins
• better filemonitor support
• new documentation (needs some gui work tho)
• lot of speedups
• lot of usability enhancements
• lots and lots of fixes

== New Plugins ==
• RegexpToolkit - helps you develop and analyze regular expressions
• QuickOpen - fast file opener for project files
• WayPoint - autogenerates waypoints when you surf and edit files and
  allows to jump back and forth


[1] http://pida.co.uk/blog/0.6beta3
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJKnGPYAAoJEFYpgV2Roepc2d4P/3VSMxAd1r3UJNS6p6jpDOLm
bES6zm0RFZmsCYdFab/WEroD24vCgO4jdmgV9woQoobuO1lecTiSGYIpbq3HcXFs
qEhiAD7jo4QdR+6josXe3crUbbUPanH4J3O4+MReOfNR+w/x3w9rT+zVGxwBa7GP
oxiFYWD9BaufHJxqVaAfRN00sGCUGVXVLwdOL2OA3T10F5hNzy9zMTKvUVjWJePG
K7xzuLeDyaxxBoZ54gMT5tg9RnCKnDfStT6qeETvRH/NkxcjFG2HJSoMkD6KtLY4
MzTJ0YbFvzp9MLxPEY/918frio5bvClRaExBdo6pOsuiIMzRrPudUlAn2fqP6Qkx
BXJRfLoXYEWmpUzzpC2zwik7ZzP2z/AwSDzJZR7ie2yKoVayGApmOeEEcePZMJUI
K2LicEcP7WdVMmzBRQcuW7A6KVlzWhhMsPig+dPiONaXDBeOncy+LXfx/9tqZ1rN
5GsrYUc94md0I7hhmo/YdYj214FKkerq5gAtwgvQBgqSo+iNL5Pu/tlGPj2b9Ph1
sZnaA2LfoiEzBIifiAD/rIY8pFcN5jCRTj44ntWWnvGQ+hAQwhjrNehrtdHaQGWD
wpaUy4TB5OlW1FFdp7dwEarTCdUqYRiVAvXrATw2g71WvVaSutEHwpNlnfFeT3tc
9fLIivMy5nnsK5W/HNf0
=Ctpz
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: An assessment of the Unicode standard

2009-09-01 Thread Byung-Hee HWANG
Nigel Rantor wig...@wiggly.org writes:

 Hendrik van Rooyen wrote:
 On Sunday 30 August 2009 22:46:49 Dennis Lee Bieber wrote:

 Rather elitist viewpoint... Why don't we just drop nukes on some 60%
 of populated landmasses that don't have a western culture and avoid
 the whole problem?

 Now yer talking, boyo!  It will surely help with the basic problem
 which is the heavy infestation of people on the planet!
 :-)

 bait
 On two conditions:

 1) We drop some test bombs on Slough to satisfy Betjeman.

 2) We strap both Xah and r to aforementioned bombs.
 /bait

 switch
 Also, I'm surprised no-one has mentioned Esperanto yet. Sounds like
 something r and Xah would *love*.

 Slightly off-topic - does anyone have a good recipe for getting
 thunderbird to kill whole threads for good? Either based on a rule or
 just some extension I can use?

 The Xah/r threads are like car crashes, I can't help but watch but my
 time could be better spent and I don't want to unsub the whole list.
 /switch

Please do not insult Xah. He spoke nothing in this threads. 

-- 
After the divorce I gave Ginny and the kids more than the courts said I 
should.
-- Johnny Fontane, Chapter 1, page 36
-- 
http://mail.python.org/mailman/listinfo/python-list


Executing python script stored as a string

2009-09-01 Thread Ecir Hana
Hello,

please, how to execute a python script stored as a string? But let me
impose several limitations, so simple exec wont work:

- if I understood it correctly defining a function in the string and
exec-ing it created the function in current scope. This is something I
really don't want

- simple exec also blocks the rest of the program

- I also would like the string to be able to use and return some parts
of the caller

So to give an example what I try to achieve:

result = []
def up(s):
  result.append(s.upper())

code = '''
up(abc)
print 'hello'
i = i + 3
def x(s):
  up(s)
x('def')
print i
'''

somehow_execute(code)

Couple of points:

- the script in string should behave just like any other ordinary
python script executed in separate process, except it should also know
about a function caller up. Nothing else. (I read that something
similar is possible while embedding python into your C project - that
you could invoke the VM and provide some default imports)

- if the other script runs in separate process how should it call the
remote function? And how to pass its arguments? I really hope I don't
have to serialize every communication, maybe I should use threading
instead of process? All I want is that running it wont block the
caller and that it cannot modify callers code/variables/scope (apart
from calling the predefined callers' functions). Or maybe even better,
let it block the caller but provide a way to stop its execution?

- how to know that the script finished? I was thinking about atexit()
- could it work here?

Think of it as a text editor with a special ability to execute its
content, while providing access of some of its functionality to the
script.

The reason I *think* I cannot just simple import the editor module
into the script is that theeditor is GUI application and script
should have access to just this instance of editor.

Anyway, I hope I was not too confusing. Thanks for any help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is behavior of += intentional for int?

2009-09-01 Thread Steven D'Aprano
On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote:

 As a result of this debate is not whether we should conclude that there
 should be two types of integers in python: 1) immutable numbers, which
 behave as constant value; 2) mutable numbers, which behave as variable
 value?

What can you do with mutable numbers that you can't do with immutable 
ones, and why do you want to do it?



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


Re: Overriding iadd for dictionary like objects

2009-09-01 Thread Aahz
In article b11a8a0e-03ca-41c9-b0d0-c5180b6a2...@p15g2000vbl.googlegroups.com,
RunThePun  ubershme...@gmail.com wrote:
On Aug 30, 10:33=A0pm, a...@pythoncraft.com (Aahz) wrote:
 In article e09276e8-8152-4002-8366-4c12705a8...@l35g2000vba.googlegroups=
.com,
 RunThePun =A0ubershme...@gmail.com wrote:

I made a DictMixin where the keys are filenames and the values are the
file contents. It was very simple and easy to do thanks to DictMixin.

For example this code writes abc in a file named temp.txt and
prints the contents of the file named swallow, these files are
looked up/created/deleted in the directory spam:
 d =3D3D FilesDict('spam')
 d['temp.txt'] =3D3D 'abc'
 print(d['swallow'])

My problem arose when I wanted to append a string to a file which
using open(..., 'ab') would have been miles more efficient because I
wouldn't have to read the entire file (__getitem__) and then write the
entire file back (__setitem__). The files are expected to be as big as
600 KB which will be appended 30 bytes at a time about 3 times a
second. Performance-wise the system would probably work without open
(..., 'ab') but it would be a real thrashing so the current solution
uses a method AddTo as Robert suggested, sacrificing the neat
getitem/setitem syntax.

 You can do mostly what you want, I think, by having __setitem__()
 convert string values into FileProxy() objects that have an appropriate
 __iadd__() method. =A0That brings a whole new set of problems, of course.

I'm guessing you meant __getitem__, which is what Jan Kaliszewski
suggested, but as you noted, would be a bit cumbersome in this case.

Actually, what I meant was __setitem__.  The idea is that you create the
proxy item when you add the data to the dict (wrapping the original
data), and the proxy has an __iadd__ method, which would allow you to do
the file append.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

I support family values -- Addams family values --www.nancybuttons.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Return value of multiprocessing manager registerred function

2009-09-01 Thread Terry
On Aug 31, 5:58 pm, jacopo jacopo.pe...@gmail.com wrote:
 Hi Terry,
 I have just started working on similar things and I am strugling to
 find examples or documentations. So far I have found only the official
 documentation of the multiprocessing package. Would you be able to
 recommend me some good reference or a book. I dont want to overwhelm
 this newsgroup with questions... yet :)
 Regards, Jacopo

 On Aug 26, 4:22 am, Terry terry.yin...@gmail.com wrote:



  Hi,

  I'm using the multiprocessing.manager to run proceduresremotely. It
  all worked fine except I hope to have a different return value type.

  The remote function calls always return a proxy, which when I need to
  get the value it need to connect to the manager again to fetch it. But
  I just need the value, not the proxy.

  Can I just return the value instead of a proxy from a manager?

  br, Terry
Hi Jacopo,
Well, I also have had a hard time to find any examples or document
except the official document. I had to read the multiprocessing source
code (they are all in python except the network connection parts). And
I found I need to hack it a little to get it work.
You can share your questions, and maybe it's common to most of us.

br, Terry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing managers and socket connection.

2009-09-01 Thread Terry
On Aug 26, 7:25 pm, Chris chris...@gmail.com wrote:
 On Aug 25, 9:11 pm, Terry terry.yin...@gmail.com wrote:





  On Aug 25, 10:14 pm, Chris chris...@gmail.com wrote:

   I've been using multiprocessing managers and I really like the
   functionality.

   I have a question about reconnecting to a manager. I have a situation
   where I start on one machine (A) a manager that is listening and then
   on another machine (B) connects to that manager and uses its proxy
   object to call functions on the manager's computer; this all works as
   expected. But, if the manager from A shuts down, B's application won't
   notice because in the MP code it ignores socket error
   errno.ECONNREFUSED. If A becomes available again or is restarted, B
   doesn't automatically reconnect either and continue its operation.
   It's function is basically stopped.

   Here is the code from connection.py:
   while 1:
           try:
               s.connect(address)
           except socket.error, e:
               if e.args[0] != errno.ECONNREFUSED: # connection refused
                   debug('failed to connect to address %s', address)
                   raise
               time.sleep(0.01)
           else:
               break

   How can I have B automatically reconnect to A and continue its work
   once A is available again?

  I think you need to retry repeatedly until successfully connected.

  br, Terry

 I'm having issue after once connected. If the server goes down during
 a long-running connection. I would want to be notified so I could try
 to reconnect. I'm doing more experimenting now and will try to post an
 example.

Hi Chris,

Are you sure that the proxy object keeps a permanent connection to the
server?

br, Terry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing python script stored as a string

2009-09-01 Thread Steven D'Aprano
On Mon, 31 Aug 2009 16:29:45 -0700, Ecir Hana wrote:

 Hello,
 
 please, how to execute a python script stored as a string? But let me
 impose several limitations, so simple exec wont work:
 
 - if I understood it correctly defining a function in the string and
 exec-ing it created the function in current scope. This is something I
 really don't want


You can pass in a global and local namespaces to exec as arguments:

 x = 4
 ns = {'x': 4}
 exec x += 1 in ns
 x
4
 ns['x']
5


See the docs for details.


 - simple exec also blocks the rest of the program


Run it in a thread.


 - I also would like the string to be able to use and return some parts
 of the caller

You can copy the parts of the current scope into the namespace you pass 
to exec, then later copy the revised values out again.

But are you sure you really want to take this approach? exec is up to ten 
times slower than just executing the code directly. And if the string is 
coming from an untrusted source, it is a *huge* security risk.



 Couple of points:
 
 - the script in string should behave just like any other ordinary python
 script executed in separate process, except it should also know about a
 function caller up. Nothing else. (I read that something similar is
 possible while embedding python into your C project - that you could
 invoke the VM and provide some default imports)

If you want it to execute in a separate *process*, that's a whole 
different question. If you do that, you get separation of code for free, 
as well as separate namespaces. My approach would be to have a special 
module common which subprocesses can import, to get access to the 
shared functions. You will probably need to create some sort of message 
passing infrastructure to get results out of the subprocess into the 
parent process. 


 - if the other script runs in separate process how should it call the
 remote function? And how to pass its arguments? I really hope I don't
 have to serialize every communication, maybe I should use threading
 instead of process? 

If you want separate processes, they're *separate*. Threads are not.


 All I want is that running it wont block the caller
 and that it cannot modify callers code/variables/scope (apart from
 calling the predefined callers' functions). Or maybe even better, let it
 block the caller but provide a way to stop its execution?

As far as I know, you can't kill threads, you can only ask them to kill 
themselves.


 - how to know that the script finished? I was thinking about atexit() -
 could it work here?

I doubt it. You would need to poll each thread to see if it has completed.



 Think of it as a text editor with a special ability to execute its
 content, while providing access of some of its functionality to the
 script.

Something like this?

In the text editor, you have contents:

text goes here
and more text
# Python script starts here
x = 'a'
up(x)
print foo
# Python script stops here
more text again


and the user selects lines 4 and 5 and chooses the command Execute. The 
script executes, and its output (foo) is appended to the end of the file:

text goes here
and more text
# Python script starts here
x = 'a'
up(x)
print foo
# Python script stops here
more text again
foo

Is this what you mean?

If so, I think you are making this much too complicated for such a simple 
use-case. Just publish an API which the script can use, and have the main 
text editor application specify a script namespace containing only that 
API. That could be a module:

 import math  # pretend this is your API shared module
 exec myvalue = 42 in math.__dict__
 math.myvalue
42



Then execute the text using exec, but don't bother about putting it into 
a thread or subprocess. That just makes it harder to implement, and you 
have to worry about concurrency issues.



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


Re: map

2009-09-01 Thread alex23
Piet van Oostrum p...@cs.uu.nl wrote:
 [myFunc(elt, 'booHoo') for elt in myList] is also a good candidate and
 in this case I think it is preferable to both the loop and the map with
 a partial or lambda in terms of clarity.

From memory, a listcomp with a non-builtin function is also faster
than map with the same.

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


Re: Executing python script stored as a string

2009-09-01 Thread Xavier Ho
On Tue, Sep 1, 2009 at 9:29 AM, Ecir Hana ecir.h...@gmail.com wrote:

 - if I understood it correctly defining a function in the string and
 exec-ing it created the function in current scope. This is something I
 really don't want


Oops, missed that point.

May I ask what is there you don't want, and what about putting the function
inside a different module and importing? What's so bad about being in
scope?

Sincerely,
-Xav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread r

Well despite all my rantings over Unicode i highly doubt Guido will
remove it from Python or any other language devs will follow suit. As
i pointed out the real issue is not so much a Unicode problem (which
is just a monkey patch) but stems from the multi-language problem.

I think a correlation can be drawn between the current state of the
world now, and the state of programming *pre* OOP. A lot of duplicate
natural languages are spread out every where like some noob's
spaghetti code. There is no intelligent all encompassing system to
reign in this unorganization.

We need an intelligent object model (universal language) to reign in
this madness.  We must wrap up the loose ends here so we can spend
more time on real problems and less time on the remedial work of
duplicating code (leaning multi-lang's) and debugging code
(miscommunication and misunderstandings between multi-lang users).

How many countless years are wasted on humans learning multiple
languages just so we can communicate? How many advancements in
medicine, physics, mathematics, blah, are we pushing further down the
road due to wasted time and energy?

But this same problem also extends into monies, nation states, units
of measure, etc. Until this multiplicity is reigned in, programmers
will suffer the agony of Unicode. Travelers to foreign lands will need
to exchange their monies And yes, *even* mechanic's will need to carry
around a set of metric and standard wrenches in their toolboxes.

What a shame :-(

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


Re: lambda functions

2009-09-01 Thread alex23
Pierre pierre.gaill...@gmail.com wrote:
 I would like to know if it is possible to define a loop in a lambda
 function

It is if you can easily replace the for loop with a call to map():

 s_minus_1 = lambda s: map(lambda x: x-1, s)
 test = range(1, 100, 10)
 test
[1, 11, 21, 31, 41, 51, 61, 71, 81, 91]
 s_minus_1(test)
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDE for python similar to visual basic

2009-09-01 Thread r
On Aug 30, 4:12 pm, Nobody nob...@nowhere.com wrote:
(snip)
 Creating a GUI programmatically is almost always the wrong approach. It
 tends to be adopted due to a path of least resistance, rather than any
 affirmative reason.

so i guess it'e safe to say that you use a GUI builder? :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: win32ui DLL Load Failed

2009-09-01 Thread Gregor Horvath
Am Mon, 31 Aug 2009 12:43:04 -0700 (PDT)
schrieb MikeC mcrav...@att.net:

 I have a python executable that's failing to load on a user's machine
 running Windows XP. My developer machine is also running Windows XP. I
 have determined that it is failing when it attempts to load win32ui.
 
 I have Python 2.6 on my developer machine and am using the pywin
 support (Mark Hammonds???) for Python 2.6.

Try to install:

http://www.microsoft.com/downloads/details.aspx?familyid=9b2da534-3e03-4391-8a4d-074b9f2bc1bfdisplaylang=en

2.6 is linked against VS8 dlls, which are missing on some machines.

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


Re: An assessment of the Unicode standard

2009-09-01 Thread Terry Reedy

r wrote:

Well despite all my rantings over Unicode i highly doubt Guido will
remove it from Python or any other language devs will follow suit. As
i pointed out the real issue is not so much a Unicode problem (which
is just a monkey patch) but stems from the multi-language problem.


Unicode is a symptom, not a fundamental cause.

[snip]


But this same problem also extends into monies, nation states, units
of measure, etc.


There is, of course, an international system of measure. The US is the 
only major holdout. (I recall Burma, or somesuch, is another.) An 
interesting proposition would be for the US to adopt the metric system 
in exchange for the rest of the world adopting simplified basic English 
as a common language.


tjr

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


Using select.kqueue()

2009-09-01 Thread Ritesh Nadhani
Hi

I am trying to use kqueue. Since, I am on v2.5, I use the baclport:
http://pypi.python.org/pypi/select26/0.1a3.

Following the example at:
http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which
works perfectly as it tells all events), I tried to port it to Python:

http://www.bpaste.net/show/25/

Not sure where I am wrong but the poller only returns *one* event
ever. Adding new text, deleting the file does not return any event.

What can I be doing wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt GUI

2009-09-01 Thread Helvin
Having left my problem with this embedding vtk business for a month, I
came back to it yesterday, and with a bit more programming knowledge,
found that my problem was simply with the python path. All I needed to
do was to append, in my GUI file,  the path to the python bindings,
which came with the source. I have blogged in more detail here:

http://learnwithhelvin.blogspot.com/2009/09/embedding-vtk-into-pyqt-gui.

My VTK stuff are now displayed in my GUI!  =D
Welcome to ask, if my blog is not detailed enough. I just wasn't
bothered to put my entire file on there.

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


Python and glade program - without errors but didn't display anything

2009-09-01 Thread Raji Seetharaman
Hi all,
i tried to develop a calculator using glade and python.
When i run the script(python calculatorglade.py), i didn't get any errors.
A calculator gui is supposed  to be displayed. But no window appears.
With Ctrl + C, i killed it. I got the following response from the terminal

^CTraceback (most recent call last):
  File calculatorglade.py, line 106, in module
gtk.main()
KeyboardInterrupt

The Python program is available here, http://pastebin.com/m44d2c1cb

The corresponding Glade xml file is available here,
http://pastebin.com/m46beaac5

What should i do to display the gui window?

Regards
Raji. S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing python script stored as a string

2009-09-01 Thread Ecir Hana
On Sep 1, 5:31 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:

 You can pass in a global and local namespaces to exec as arguments:

  x = 4
  ns = {'x': 4}
  exec x += 1 in ns
  x
 4
  ns['x']

 5

 See the docs for details.

Thanks! This is very useful!

 You can copy the parts of the current scope into the namespace you pass
 to exec, then later copy the revised values out again.

 But are you sure you really want to take this approach? exec is up to ten
 times slower than just executing the code directly. And if the string is
 coming from an untrusted source, it is a *huge* security risk.

I don't know if I should use exec. I don't really mind that it's slow
(btw., why is it so?). But I don't quite understand why is it security
risk. How is it different to run:
exec 'format(your_hdd)'
than:
/bin/python format.py
?

 As far as I know, you can't kill threads, you can only ask them to kill
 themselves.

Also, I'm not sure if I follow. What does this mean? If a thread runs:

while True:
  pass

it is not possible to kill it from another thread? (Bacause it doesn't
check whether some other thread asks to stop it..?)

 Something like this?

Well, something more like:

data = [1, 2, 3]
map(lambda x: x * 2, data)
display_data_in_editor_viewport(data) #this renders into part of main
editor window (may take some time)

 If so, I think you are making this much too complicated for such a simple
 use-case. Just publish an API which the script can use, and have the main
 text editor application specify a script namespace containing only that
 API. That could be a module:

  import math  # pretend this is your API shared module
  exec myvalue = 42 in math.__dict__
  math.myvalue

 42

 Then execute the text using exec, but don't bother about putting it into
 a thread or subprocess. That just makes it harder to implement, and you
 have to worry about concurrency issues.

Ok, I could try exec, thanks for the explanation. But what about those
security concerns you mentioned above?

Thanks a lot, very informative!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Executing python script stored as a string

2009-09-01 Thread Steven D'Aprano
On Tue, 01 Sep 2009 01:34:33 -0700, Ecir Hana wrote:

 You can copy the parts of the current scope into the namespace you pass
 to exec, then later copy the revised values out again.

 But are you sure you really want to take this approach? exec is up to
 ten times slower than just executing the code directly. And if the
 string is coming from an untrusted source, it is a *huge* security
 risk.
 
 I don't know if I should use exec. I don't really mind that it's slow
 (btw., why is it so?).

Because it has to parse and compile the string into a code object before 
it can run it. 


 But I don't quite understand why is it security
 risk. How is it different to run:
 exec 'format(your_hdd)'
 than:
 /bin/python format.py
 ?

It's not different. But read what I said -- if the string is coming from 
an UNTRUSTED source -- presumably you trust yourself. If you run 'exec 
format(your_hdd)' it is because *you* want to format your hard disk.

Now imagine you have a web-app which gets a string from the user and 
calls exec on it. Then you might have this:

exec search('%d') % user_input

and the user, who is halfway across the world, enters the following 
search string:

places to eat'); import os; os.system('#rm -rf /

Your web app will go right ahead and erase itself. That's why you need to 
keep untrusted strings away from exec, execfile, and eval.



 As far as I know, you can't kill threads, you can only ask them to kill
 themselves.
 
 Also, I'm not sure if I follow. What does this mean? If a thread runs:
 
 while True:
   pass
 
 it is not possible to kill it from another thread? (Bacause it doesn't
 check whether some other thread asks to stop it..?)

No, I believe that the only way to halt that is to halt the entire 
process.

Possibly there is a way to have a thread halt itself after a certain 
amount of time? I'm not an expert on threads, I've hardly ever used them.



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


Python word to text

2009-09-01 Thread BJörn Lindqvist
Hello everybody,

I'm looking for a pure Python solution for converting word documents
to text. App Engine doesn't allow external programs, which means that
external programs like catdoc and antiword can't be used. Anyone know
of any?

Thanks in advance.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-01 Thread Andre Engels
On Sun, Aug 30, 2009 at 11:18 AM, David71da...@libero.it wrote:
 Il Sat, 29 Aug 2009 17:18:46 -0700 (PDT), casebash ha scritto:

 So much of it could be removed even by simple keyword filtering.

 I think there is only one final solution to the spam pestilence: a tiny tax
 on email and posts.
 Spammers send hundreds of thousands of emails/posts a day and a tax of
 0.0001$ each does not harm normal users but discurages spammers. This tax
 should be applied when a message is routed by a ISP server, this saves
 mails/posts internal to a LAN.

What about mailing lists? There exist well-functioning mailing lists
with thousands of subscribers. Being a posting member of those will
significantly increase your internet bill under your proposal.


-- 
André Engels, andreeng...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and glade program - without errors but didn't display anything

2009-09-01 Thread anusha k
hi,
You forgot to show the window.So in init method of py file and add

self.window = self.wTree.get_widget(window_calculator)
self.window.show()



Njoy the share of Freedom,
Anusha Kadambala
On Tue, Sep 1, 2009 at 2:04 PM, Raji Seetharaman sraji...@gmail.com wrote:

 Hi all,
 i tried to develop a calculator using glade and python.
 When i run the script(python calculatorglade.py), i didn't get any errors.
 A calculator gui is supposed  to be displayed. But no window appears.
 With Ctrl + C, i killed it. I got the following response from the terminal

 ^CTraceback (most recent call last):
   File calculatorglade.py, line 106, in module
 gtk.main()
 KeyboardInterrupt

 The Python program is available here, http://pastebin.com/m44d2c1cb

 The corresponding Glade xml file is available here,
 http://pastebin.com/m46beaac5

 What should i do to display the gui window?

 Regards
 Raji. S

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


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


Re: Executing python script stored as a string

2009-09-01 Thread Ecir Hana
On Sep 1, 11:32 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
  But I don't quite understand why is it security
  risk. How is it different to run:
  exec 'format(your_hdd)'
  than:
  /bin/python format.py
  ?

 It's not different. But read what I said -- if the string is coming from
 an UNTRUSTED source -- presumably you trust yourself. If you run 'exec
 format(your_hdd)' it is because *you* want to format your hard disk.

 Now imagine you have a web-app which gets a string from the user and
 calls exec on it. Then you might have this:

 exec search('%d') % user_input

 and the user, who is halfway across the world, enters the following
 search string:

 places to eat'); import os; os.system('#rm -rf /

 Your web app will go right ahead and erase itself. That's why you need to
 keep untrusted strings away from exec, execfile, and eval.

Ah, I see! Ok.

 No, I believe that the only way to halt that is to halt the entire
 process.

 Possibly there is a way to have a thread halt itself after a certain
 amount of time? I'm not an expert on threads, I've hardly ever used them.

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


Re: Executing python script stored as a string

2009-09-01 Thread Hendrik van Rooyen
On Tuesday 01 September 2009 11:32:29 Steven D'Aprano wrote:

 Possibly there is a way to have a thread halt itself after a certain
 amount of time? I'm not an expert on threads, I've hardly ever used them.

Not automagically, as far as I can see.
You are on your own if you want to somehow kill a thread.

What I do is to wrap what I want to do in a while clause:

while runbool:
do_what_you_want()

where runbool is a global that I set to false elsewhere when I want to stop.

There is of course nothing to stop you writing a thread with something like:

import time
start_time = time.time()
while time.time() - start_time  some_parameter:
do_what_you_want()

Which will have the effect of running for a while and then stop.
I cannot see much use use for that as it is, as it will be bloody-minded about 
the time, and might chop off before the whole job is done, but one could make 
it more intelligent, such that it keeps track of idle time, and aborts after 
say a second (or a minute) of not doing anything useful.

Unlike you, I am a thread and queue fanatic - use them all the time.

- Hendrik

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


Re: Python word to text

2009-09-01 Thread Nitebirdz
On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:
 Hello everybody,
 
 I'm looking for a pure Python solution for converting word documents
 to text. App Engine doesn't allow external programs, which means that
 external programs like catdoc and antiword can't be used. Anyone know
 of any?
 

A quick search returned this:

http://code.activestate.com/recipes/279003/


Did you give it a try?  


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


Re: Using select.kqueue()

2009-09-01 Thread exarkun

On 07:51 am, rite...@gmail.com wrote:

Hi

I am trying to use kqueue. Since, I am on v2.5, I use the baclport:
http://pypi.python.org/pypi/select26/0.1a3.

Following the example at:
http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which
works perfectly as it tells all events), I tried to port it to Python:

http://www.bpaste.net/show/25/

Not sure where I am wrong but the poller only returns *one* event
ever. Adding new text, deleting the file does not return any event.

What can I be doing wrong?


Perhaps you are encountering http://bugs.python.org/issue5910

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


Re: map

2009-09-01 Thread Jan Kaliszewski

Another possibilities, if you really *desire* to use map()
and not list-comprehension (I'd prefer the latter), are:

# Python 2.x:
map(func, mylist, itertools.repeat('booHoo', len(mylist)))

# Python 3.x, where map() works like Py2.x's itertools.imap():
list(map(func, mylist, itertools.repeat('booHoo')))

Cheers,
*j

--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread Kurt Mueller

Am 01.09.2009 um 09:39 schrieb Terry Reedy:


But this same problem also extends into monies, nation states, units
of measure, etc.


There is, of course, an international system of measure. The US is  
the only major holdout. (I recall Burma, or somesuch, is another.)  
An interesting proposition would be for the US to adopt the metric  
system in exchange for the rest of the world adopting simplified  
basic English as a common language.


The SI-system is nearly universally employed.
Three principal exceptions are Burma (Myanmar), Liberia, and the  
United States.
The United Kingdom has officially adopted the International System of  
Units

but not with the intention of replacing customary measures entirely.
inline: Bild 4.png


When I was a student, they told us, that in a couple of years there  
will be

the SI-system only, because most countries accepted it in their laws.
So we should adopt it.
That was in the early 70ties.
Only this year we have to deliver results of technical processes to  
british

and US companies. They still want them in their crazy outdated units.


The other thing would be the US to adopt a simplified basic English.
I would not be astonished, that british people would state,
that they already do :-)



Grüessli-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread Paul Boddie
On 30 Aug, 18:00, r rt8...@gmail.com wrote:

 Hold the phone Paul you are calling me a retarded bigot and i don't
 much appreciate that. I think you are completely misinterpreting my
 post. i and i ask you read it again especially this part...

I didn't call you a retarded bigot, and yet I did read your post.

[...]

 I don't really care what language we adopt as long as we choose *only*
 one and then seek to perfect it to perfection. And also that this
 *one* language use simplicity as it's model. English sucks, but
 compared to traditional Chinese and Egyptian Hieroglyphs it's a god
 send.

You don't care which language it is as long as it's the one you use.
That's what this sounds like, layered on top of what you've already
written (and what you write below). How about Esperanto? You have
heard of Esperanto, right? Or take your pick from the other artificial
languages - they're relatively popular in some places where English
isn't the natural first-choice foreign language.

[...]

 Look history is great but i am more concerned with the future. Learn
 the lessons of the past, move on, and live for the future. If you want
 to study the hair styles of Neanderthal women be my guest. Anybody
 with half a brain knows the one world government and language is
 coming. Why stop evolution, it is our destiny and it will improve the
 human experience.

Again, we witness a distortion of scientific concepts through the use
of political themes.

 [Warning: facts of life ahead!!]

Even Xah Lee's harshest critics must acknowledge that Xah delivers a
less offensive, more entertaining rant than this. At least Xah has
mastered the art of the expletive.

 I'll bet you weep and moan for the native Americans who where
 slaughtered don't you? Yes they suffered a tragic death as have many
 poor souls throughout history and yes they also contributed to human
 history and experience, but their time had come and they can only
 blame themselfs for it.

You're on a slippery slope when you claim that people deserve whatever
mistreatment or misfortune comes their way through mere circumstances
of birth. I suggest you step back and actually read your messages
again and consider how others might interpret them.

I also suggest that, unless you really wish to discuss deficiencies of
Unicode with respect to Python, you don't use this list/group as a
discussion forum for your ill-informed notions of progress, but
instead take them to a more appropriate forum where I'm sure people
will be happy to scrutinise your ideas at their leisure.

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


Re: An assessment of the Unicode standard

2009-09-01 Thread Paul Boddie
On 31 Aug, 00:28, r rt8...@gmail.com wrote:

 I said it before and i will say it again. I DONT CARE WHAT LANGUAGE
 WE USE AS LONG AS IT IS A MODERN LANGUAGE FOUNDED ON IDEALS OF
 SIMPLICITY

[Esperanto]

 English is by far already the de-facto lingua franca throughout the
 world.

You don't care, but here it comes: English! And is it a language
founded on ideals of simplicity? I suggest you familiarise yourself
with the history of the English language.

[...]

 You can deny the holocaust all you want but it still happened and so
 too shall the great unity! Sadly because of cultural and social
 fanatics like yourself, it will probably take another great war to
 usher in the new order.

Now you are just being offensive.

[...]

 So you are advocating for me to use derogatory statements in my post,
 no thanks i need not resort to adolescent rants to argue my points.

So what was the bulk of your opening message in this thread or the
kind of gutter remarks made above if not adolescent rants?

 And why do you continue to compare me to XL. Has XL *ever* helped a
 python user in this forum? I have, many times. I am *actually* a
 python programmer who cares about Python and my posts bring much vigor
 and intelligence to an otherwise boring NG -- like me or not.

Whether you actually care about Python or not, I repeat my suggestion
that you take rants of this nature out of this forum and to a more
appropriate place. At the very time the community seeks to increase
diversity, such material is not only insensitive towards those who do
not share your own cultural and political background, it also
demonstrates a total lack of awareness of the kind of community people
are trying to build and sustain.

And don't give us the livening up the newsgroup excuse. The only
reason people use newsgroups like this for their political posturing
is analogous to a football player bursting into a chess club and
claiming superiority in his own sport over those whose pastime has
been interrupted: he knows that in a more suitable venue, his
inadequacy would quickly be revealed by active practitioners of the
discipline. Take your material elsewhere - maybe then the historians,
linguists and sociologists will give you the tuition you so richly
deserve!

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


Re: Determining the metaclass

2009-09-01 Thread casebash
Thanks, I am silly



  I cannot determine if a class is an instance of a particular
  metaclass. Here is my best attempt

   class tmp(type):

  ...     pass
  ... def c(metaclass=tmp):

  ...     pass
  ... isinstance(c, tmp)
  False
   isinstance(c.__class__, tmp)

  False

  Can anyone explain why this fails?

 You're gonna kick yourself.

 It's because you used def and not class to define c.  If you'd
 used class then then first test would have worked.

 Carl Banks

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


Re: Why does this group have so much spam?

2009-09-01 Thread David
Il Sun, 30 Aug 2009 19:13:38 +0100, Nobody ha scritto:

 Apart from the impossibility of implementing such a tax, it isn't going to
 discourage spammers when the tax will be paid by the owner of the
 compromised PC from which they're sending their spam.

I don't agree.
Each computer connected to internet is phisically connected to a carrer's
hub. Each carrier can easily count smtp packets of each user as they can
detect, filter and in some nations prosecute, p2p users.

The owner of compromised PC should be responsible of his computer like the
owner of a car is responsible of damages caused by its car. 
That owner should keep his computer clean as he *must* keep his car
functional and safe. 
Today most of the people consider cyber security an optional, but all of us
pay for their negligence. Those people are externalizing to the rest of the
world their costs in terms of SO updating, antivirus, firewall and
knowledge. This is unfair.
This is mainly a matter of sensibility and culture: in '50/60s active and
passive car safety was an optional, today is a must.
I think it's time to switch to responsible computing and the mail-tax would
charge each person of its own costs and annoyances without affectig the rest
of the world.

 
 If you want to avoid usenet spam and don't want to filter it yourself,
 find a provider with more aggressive spam filter. 

This is not the solution. You are saying that if your neighbour makes loud
noises you can not call police to impose him to cease but you can only make
your home soundproof.

 Ultimately, it's up to
 the person running the news server as to which posts they will or will not
 accept.

Are you suggesting to moderate every news server and mail server all over
the world? THIS is impossible!

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


Re: Why does this group have so much spam?

2009-09-01 Thread David
Il Sun, 30 Aug 2009 16:08:46 -0700 (PDT), r ha scritto:


 Yes i agree but your logic is flawed. If someone cuts my brake lines
 and i cannot stop who is to blame? Or if someone throws nails on the
 highway and i crash, who is to blame? Obviously you cannot blame the
 car owner. However if i let my brake pads wear out until they are
 metal on metal and run over some poor old lady crossing the street --
 well now you got me! ;)
 
 But you cannot apply this logic when a hacker compromises someones
 computer, it the same as cutting their brake lines. How can you
 honestly expect that Joe computer user will know of this infection? 

I expect that user makes periodical and hopefully frequent checks to his
computer. Today most of the people simply does absolutely nothing.
Obvioulsy there is a vulnerability time between two check, but Perfection
does not belongs to human beings so we must accept the risk of being cracked
and being aware that we will charged for our computer actions, even if we
are not directly responsible.
It's a question of point of view: in italy if a thief steals a car and
causes an accident the car's owner's assurance (having a car assurance is
mandatory) must refund the victims. That's because protections of victims is
first priority.
Obviously the owner can not be charged 


Do
 you even know where your brake lines are? Even hackers can be hacked
 without ever knowing it! The only sure fire way is VM's or system re-
 installs.

That's a problem of the computer owner. Why should the rest of the world be
charged of *his* problem while keeping him safe from suffering any
consequence?

[...]
 I think it's time to switch to responsible computing and the mail-tax would
 charge each person of its own costs and annoyances without affectig the rest
 of the world.
 
 What, this is madness! If you have terrorist terrorizing your country
 you don't tax the public when they blow up a shopping mall so you can
 rebuild it! No you kill the terrorist in a harsh and painful manner
 and make an example of them, then you seize there monies. You should
 direct your anger to the proper internet security authorities(and more
 importantly to the perpetrator's) and not the innocent victims of such
 attacks. I want you to sit back and think very deeply about your
 proposal here because it is horribly wrong.

Madness, you say? Let's examine the situation a bit moore deeply.

First, the mail-tax would is not for rebuilding the destroyed building after
the attack but, at the opposite, to prevent the attack. Wouldn't you pay a
small tax to prevent terrorist's attacks?
The mail-tax would be really small, if you send 1000 mails at month (a real
huge traffic, for a non spammer!) the bill would be about 10 cents. 
Do you really think this is too much to get rid of most of the spam?

Second, today we *are* paying that tax to repair building destroyed by
terrorists. 
We are paying and hidden tax in terms of HW and human resources needed by
ISPs to manage that huge (~90%) useless/malicius traffic. (I don't mention
const related to dalays, denial of services, theft of informations...)
Those costs are obviously charged by ISPs on our montly subscription bill. 
By the mail-tax we achive 3 results: 
1. stopping forever direct spammers.
2. make each owner aware that his computer is compromised when the montly
bill is higher than usual.
3. make that owner aware that *he* must pay for *his* problem and the rest
of the world (included, I hope, you) is no more willing to be charged for
this.

The mail-tax may not be Final Solution against spam, but helps a lot.

 
 It is so easy to just slap a tax on something, yes that will solve
 everything. *sarcasm*

You should reconsider your position because you are actually blaming the
present situation, not my proposal.
Finally a little criticims: spam and related malware is a problem growing
day by day. I am proposing a solution and if somebody doest't like it, well,
he should propose a better one. Just saying NO! and turning head aside
hoping that the problem will solve by itsef is no more acceptable.

 
 If you want to avoid usenet spam and don't want to filter it yourself,
 find a provider with more aggressive spam filter.

 This is not the solution. You are saying that if your neighbour makes loud
 noises you can not call police to impose him to cease but you can only make
 your home soundproof.
 
 or you could go over and punch him in the nose, works every time for
 me ;-)

In italy we say: preventing is better than treating (a disease).

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


Re: Why does this group have so much spam?

2009-09-01 Thread David
Il Mon, 31 Aug 2009 21:04:27 +0200, David ha scritto:


 Obviously the owner can not be charged 
I mean: can not be jailed for crimes made by the thief using his car.

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


Re: Select column from a list

2009-09-01 Thread hoffik

Wow, I didn't expect so many answers and possibilities! I'll try to go
through it and surely find the best solution for me :jumping:

Thank you all!
-- 
View this message in context: 
http://www.nabble.com/Select-column-from-a-list-tp25185508p25240207.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: An assessment of the Unicode standard

2009-09-01 Thread Matthew Barnett

Kurt Mueller wrote:

Am 01.09.2009 um 09:39 schrieb Terry Reedy:


But this same problem also extends into monies, nation states, units
of measure, etc.


There is, of course, an international system of measure. The US is the 
only major holdout. (I recall Burma, or somesuch, is another.) An 
interesting proposition would be for the US to adopt the metric system 
in exchange for the rest of the world adopting simplified basic 
English as a common language.


The SI-system is nearly universally employed.
Three principal exceptions are Burma (Myanmar), Liberia, and the United 
States.

The United Kingdom has officially adopted the International System of Units
but not with the intention of replacing customary measures entirely.


The intention in the UK was to switch to SI over a period of 10 years,
starting in 1971, so from then only SI was taught in schools.

Earlier this year the EU decided that it wouldn't force the UK to
abandon the few remaining uses of the Imperial system; SI is preferred,
but Imperial is permitted. The roads are still Imperial, and milk
delivered to the door can still use the existing pint bottles, but milk
sold in shops is in SI.






When I was a student, they told us, that in a couple of years there will be
the SI-system only, because most countries accepted it in their laws.
So we should adopt it.
That was in the early 70ties.
Only this year we have to deliver results of technical processes to british
and US companies. They still want them in their crazy outdated units.


The other thing would be the US to adopt a simplified basic English.
I would not be astonished, that british people would state,
that they already do :-)


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


Re: An assessment of the Unicode standard

2009-09-01 Thread r
On Aug 30, 1:08 pm, Nobody nob...@nowhere.com wrote:
(snip)
 Because that would be the likely consequence of such a stance. Japanese
 websites will continue to use Shift-JIS, Japanese cellphones (or
 Scandanavian cellphones aimed at the Japanese market, for that matter)
 will continue to render websites which use Shift-JIS, and HTML 5 will be
 just as much a pure academic exercise as all of the other HTML standards.

Yes and this keep-everyone-happy crap will go on for centuries.
Unicode will then turn into another elephant sized bloatware standard
that only VB and MSDN, M$ Office, and Adobe PDF can hold a candle to.
Who cares, hard drives can hold terabytes of useless junk, right?

This is starting to border on OCD tendencies and i for one am getting
very nervous.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and glade program - without errors but didn't display anything

2009-09-01 Thread Raji Seetharaman
Thanks Anusha. Now my calculator gui window is displayed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE file saving problem

2009-09-01 Thread r
On Aug 23, 4:12 am, Harald Luessen harald.lues...@gmx.de wrote:
(snip)
 When the cursor is somewhere in the white space at the
 beginning of the lines and I use Ctrl-rightArrow  [ctrl]-[-]
 to go to the first word in the line then IDLE skips
 the position with the first non-whitespace letter and places
 the cursor after the first word in the line.
 This is not consistent because moving backwards works. [ctrl]-[-]
 Similar things happen at the end of a line.

Ah yes, this is something that erks me daily, but i seem to have
forgotten about it until you brought it up (Thank you!). I must put
this on the rIDLE bug list. It's these tiny annoyances that really
ruin IDLE. It's noting major, but you know what a thousand paper-cuts
can do... With a little spit shine IDLE could be quite wonderful.

You guys will see a much improved IDLE very soon, i can promise you
that!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object Reference question

2009-09-01 Thread Bruno Desthuilliers

Ethan Furman a écrit :
(snip)

The best answer I can give is that you do not want to use 'name' to 
reference the object itself, but only for printing/debugging purposes. 


Which is what the OP stated !-)

'name' is just a label for your object, and not necessarily the only 
label;  that particular label may also be lost... Consider:


(snip example)

As you can see, just because you have saved the original name does not 
gaurantee that same name will always reference that same object, or any 
object.



FWIW, the __name__ attributes of functions, classes and modules works 
just the same...

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


Re: Python word to text

2009-09-01 Thread BJörn Lindqvist
2009/9/1 Nitebirdz nitebi...@sacredchaos.com:
 On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:
 Hello everybody,

 I'm looking for a pure Python solution for converting word documents
 to text. App Engine doesn't allow external programs, which means that
 external programs like catdoc and antiword can't be used. Anyone know
 of any?


 A quick search returned this:

 http://code.activestate.com/recipes/279003/

It requires windows.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python word to text

2009-09-01 Thread Tino Wildenhain

Am 01.09.2009 13:42, schrieb Nitebirdz:

On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:

Hello everybody,

I'm looking for a pure Python solution for converting word documents
to text. App Engine doesn't allow external programs, which means that
external programs like catdoc and antiword can't be used. Anyone know
of any?



A quick search returned this:

http://code.activestate.com/recipes/279003/


Did you give it a try?


Thats a funny advice. Did you read that receipe? ;-)
Requires the Python for Windows extensions, and MS Word.
how does this match with App Engine doesn't allow external programs? :-)

For excel this would be easy but word - Björn, did you check google api
if you would be able to access google docs for this?

Regards
Tino



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python word to text

2009-09-01 Thread Tim Golden

BJörn Lindqvist wrote:

2009/9/1 Nitebirdz nitebi...@sacredchaos.com:

On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:

Hello everybody,

I'm looking for a pure Python solution for converting word documents
to text. App Engine doesn't allow external programs, which means that
external programs like catdoc and antiword can't be used. Anyone know
of any?


A quick search returned this:

http://code.activestate.com/recipes/279003/


It requires windows.


I'm moderately confident that no (published) solution exists
for this without relying on an installed Word or an external
program of the kind you mentioned. Obviously, there's nothing
to stop someone creating a Python module which does the
equivalent, possibly by wrapping the core of the catdoc/antiword
code in a Python module or by recoding its functionality in
Python. But I imagine you knew that :)

If you were talking Excel, you'd be in luck thanks to the
sterling work done by John Machin and others. But I imagine
that the market for word doc interchange / conversion is
considerably smaller, especially within restricted environments.

Depending on the source of your docs, it would be possible to
save them as, eg, XML or something for which a converter is
available in Python. Even text-only, I suppose. But I suppose
that you're asking because that's not a possibility?

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


Re: Is behavior of += intentional for int?

2009-09-01 Thread zaur
On 1 сен, 03:31, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote:
  As a result of this debate is not whether we should conclude that there
  should be two types of integers in python: 1) immutable numbers, which
  behave as constant value; 2) mutable numbers, which behave as variable
  value?

 What can you do with mutable numbers that you can't do with immutable
 ones, and why do you want to do it?

 --
 Steven

Mutable numbers acts as variable quantity. So when augmented
assignment is used there is no need to create a new number object in
every binary operation.

But when I looked now into source of python int (longobject.c) I
realized that direct implementation of mutable int will not give any
benefit against defining proxy int class, which supports mutability.
-- 
http://mail.python.org/mailman/listinfo/python-list


copy object?

2009-09-01 Thread lallous
Hello

I am new to python and have some questions.

How to copy objects using another method than this:

class op:
  def __init__(self, op):
for x in dir(op):
  if x[:2] == __:
continue
  setattr(self, x, getattr(op, x))

o = op(src)

I tried to copy with o = copy.copy(src) but as soon as src is
gone, o's attributes are not correct, and I cannot use copy.deepcopy
() because of this error:
TypeError: object.__new__(SwigPyObject) is not safe, use
SwigPyObject.__new__()

Can the previous for loop be simplified and replaced with a map() and
a lambda function?

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


Re: Python word to text

2009-09-01 Thread Gabriel
2009/9/1 BJörn Lindqvist bjou...@gmail.com:
 Hello everybody,

 I'm looking for a pure Python solution for converting word documents
 to text. App Engine doesn't allow external programs, which means that
 external programs like catdoc and antiword can't be used. Anyone know
 of any?


You could use the google docs api
(http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#DownloadingDocsAndPresentations)

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


Python community buildbot page still 503

2009-09-01 Thread Graeme Glass
If I am not mistaken http://python.org/dev/buildbot/community/all/ has
been down since python.org had its harddrive issues.

Anyone know a time line on getting it back up and running.
I have mailed the buildbot mailing list, but heard nothing for a week,
so thought I would try here.

Kind regards,
Graeme
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread steve

I'm a lurker on this list and am here more to learn rather than teach and
although better sense tells me not to feed the troll -- I'll bite.

Mainly because, r, unlike XL does seem to offer help every one in a while.

So, ...

On 08/31/2009 03:58 AM, r wrote:

On Aug 30, 2:05 pm, Paul Boddiep...@boddie.org.uk  wrote: (snip)

You don't care which language it is as long as it's the one you use. That's
what this sounds like, layered on top of what you've already written (and
what you write below).


I said it before and i will say it again. I DONT CARE WHAT LANGUAGE WE USE
AS LONG AS IT IS A MODERN LANGUAGE FOUNDED ON IDEALS OF SIMPLICITY


I think you are confusing simplicity with uniformity.

Uniformity is not always good. Sure standardizing on units of measure and 
airline codes is good, but expecting everyone to speak one language is akin to 
expecting everyone to wear one type of clothing or expecting everyone to drive 
just one type of automobile -- those kind of rules works well in a small sets 
where doing so fulfills a purpose (in the army, hospitals or taxi service, for 
instance).


The problems associated with enforcing uniformity within larger sets are often 
_less_ _simple_ than finding _solutions_ to deal with _complexity_ (your 
misplaced philosophical rhetoric about how one-world-one-language-would-usher 
in-a-golden-age aside -- /that/ you should take up with any person of science 
and be ready to be laughed at).


To put it another way, it is better to create data structures to deal with 
variable length names rather than mandating that everybody has names  30 chars.


If you fail to understand how that applies to unicode, you sadly will have 
trouble understanding the existence of not only unicode, but also of TCP/IP, 
timezones, xml and the whole concept of Interfaces.


[...snip...]

Paul: civilizations rise and fall, this is beyond our control. Every great
power will utter fail at some point. Some die out like a slow burning candle,
others go quickly and painfully from defeating blows in war time. This is an
eventuality you must face friend. This whole save the whales BS is really
getting on my nerves! Stop trying to play God Paul, it is not your decision
when and where the blade shall fall.

When a people stop evolving and no longer have anything productive to give to
evolution, evolution stamps them out. If the Indians had developed gun power
and industrialized America they might be running more than merely a casino.
Oh No! Was that out of line, you will probably think so.

Stay in know and you shall endure...


This might come as a bit of shock for you, but evolution awards those who are
capable of adapting to complexity rather then those who expect things to be
uniform. You, dear friend, and those who yearn for uniformity are the ones on 
the path to extinction.


cheers,
- steve
--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ban Xah Lee

2009-09-01 Thread markspace

Gernot Hassenpflug wrote:



Crap, what the hell are *you* doing here, Arved. This is so frightening!

LOL
Gernot (shocked to find people have other interests, hehe)



Thanks for cross posting this to five different newsgroups.  Your 
garbage is not wanted here, here being clj.programmer.  Learn to use you 
newsreader and check where you posts are going before you send them.


Followup's sent to alt.flame.
--
http://mail.python.org/mailman/listinfo/python-list


AttributeError: 'NoneType' object has no attribute 'get_text'

2009-09-01 Thread Raji Seetharaman
Hi all, i worked out python and glade example program to add two numbers and
display its output from the following link
http://www.dreamincode.net/forums/showtopic63885.htm
When i run the script, i received the following error

python add.py
Traceback (most recent call last):
  File add.py, line 34, in add
thistime = adder( self.wTree.get_widget(entryNumber1).get_text(),
self.wTree.get_widget(entryNumber2).get_text())
AttributeError: 'NoneType' object has no attribute 'get_text'

What has to be done to overcome this error?

Regards

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


Re: Logging contents of IRC channel

2009-09-01 Thread Dan Upton
http://www.irchelp.org/irchelp/rfc/rfc.html describes (more or less) the
protocol.  It's actually pretty easy to write something which can connect
and monitor one or more channels on a server--that's how I learned network
programming in Java many moons ago.  I'd say look at the RFC and start off
logging all of your sent and received messages to the console, so if it
hangs you can see what message you've gotten and look up how to respond to
it.

-dan

On Mon, Aug 31, 2009 at 11:56 AM, Jonathan Gardner 
jgard...@jonathangardner.net wrote:

 On Aug 31, 10:23 am, devaru ajoys...@gmail.com wrote:
  I am new to Python. I want to log the activities in an IRC channel.
  Any pointers regarding this would be of great help.

 How are you going to plug into the chat server to obtain the data?

 How will you store the data?

 The in between parts are really easy.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Python word to text

2009-09-01 Thread Nitebirdz
On Tue, Sep 01, 2009 at 03:20:29PM +0200, Tino Wildenhain wrote:

 A quick search returned this:

 http://code.activestate.com/recipes/279003/


 Did you give it a try?

 Thats a funny advice. Did you read that receipe? ;-)
 Requires the Python for Windows extensions, and MS Word.
 how does this match with App Engine doesn't allow external programs? :-)


Sorry, you're absolutely right.  I did notice it required Windows, but
didn't see any comments in the original message that this wasn't to be
run on Windows.  As for the issue regarding external programs, I assumed
it only referred to the ones explictly mentioned or similar (catdoc,
antiword, etc.).  

My apologies.

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


Re: [ANN] Pida 0.6beta3

2009-09-01 Thread Gary Herron

poelzi wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

We are proud to announce the hopfully last beta of Pida 0.6. [1]
  


Wouldn't this be a good time to tell us what Pida does?



It was a long time since beta2 and a lot of changes happened since then:

== Core Highlights ==
• multiprocessing language plugins
Language plugins can now use a multiprocessing infrastructure which
allows expensive operations to be done on other cpu cores. This
increases the speed of plugins like python_lint and python
dramatically and do not make the gui sluggish anymore.
• project file caches
Projects now have a filecache which allows fast queries to filenames
and filetypes. The QuickOpen plugin provides a gui for this,
allowing the user to open files to which parts of the name, path or
filetype are known
• very precise feature selection from LanguagePlugins
• better filemonitor support
• new documentation (needs some gui work tho)
• lot of speedups
• lot of usability enhancements
• lots and lots of fixes

== New Plugins ==
• RegexpToolkit - helps you develop and analyze regular expressions
• QuickOpen - fast file opener for project files
• WayPoint - autogenerates waypoints when you surf and edit files and
  allows to jump back and forth


[1] http://pida.co.uk/blog/0.6beta3
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJKnGPYAAoJEFYpgV2Roepc2d4P/3VSMxAd1r3UJNS6p6jpDOLm
bES6zm0RFZmsCYdFab/WEroD24vCgO4jdmgV9woQoobuO1lecTiSGYIpbq3HcXFs
qEhiAD7jo4QdR+6josXe3crUbbUPanH4J3O4+MReOfNR+w/x3w9rT+zVGxwBa7GP
oxiFYWD9BaufHJxqVaAfRN00sGCUGVXVLwdOL2OA3T10F5hNzy9zMTKvUVjWJePG
K7xzuLeDyaxxBoZ54gMT5tg9RnCKnDfStT6qeETvRH/NkxcjFG2HJSoMkD6KtLY4
MzTJ0YbFvzp9MLxPEY/918frio5bvClRaExBdo6pOsuiIMzRrPudUlAn2fqP6Qkx
BXJRfLoXYEWmpUzzpC2zwik7ZzP2z/AwSDzJZR7ie2yKoVayGApmOeEEcePZMJUI
K2LicEcP7WdVMmzBRQcuW7A6KVlzWhhMsPig+dPiONaXDBeOncy+LXfx/9tqZ1rN
5GsrYUc94md0I7hhmo/YdYj214FKkerq5gAtwgvQBgqSo+iNL5Pu/tlGPj2b9Ph1
sZnaA2LfoiEzBIifiAD/rIY8pFcN5jCRTj44ntWWnvGQ+hAQwhjrNehrtdHaQGWD
wpaUy4TB5OlW1FFdp7dwEarTCdUqYRiVAvXrATw2g71WvVaSutEHwpNlnfFeT3tc
9fLIivMy5nnsK5W/HNf0
=Ctpz
-END PGP SIGNATURE-
  



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


Re: An assessment of the Unicode standard

2009-09-01 Thread Rami Chowdhury

SI is preferred,
but Imperial is permitted.


IME most people in the UK under the age of 40 can speak SI without trouble.

On the other hand, let's nip down to the pub for 580ml of beer just  
doesn't have the right ring to it ;-)


On Tue, 01 Sep 2009 06:17:00 -0700, Matthew Barnett  
mrabarn...@mrabarnett.plus.com wrote:



Kurt Mueller wrote:

Am 01.09.2009 um 09:39 schrieb Terry Reedy:


But this same problem also extends into monies, nation states, units
of measure, etc.


There is, of course, an international system of measure. The US is the  
only major holdout. (I recall Burma, or somesuch, is another.) An  
interesting proposition would be for the US to adopt the metric system  
in exchange for the rest of the world adopting simplified basic  
English as a common language.

 The SI-system is nearly universally employed.
Three principal exceptions are Burma (Myanmar), Liberia, and the United  
States.
The United Kingdom has officially adopted the International System of  
Units

but not with the intention of replacing customary measures entirely.


The intention in the UK was to switch to SI over a period of 10 years,
starting in 1971, so from then only SI was taught in schools.

Earlier this year the EU decided that it wouldn't force the UK to
abandon the few remaining uses of the Imperial system; SI is preferred,
but Imperial is permitted. The roads are still Imperial, and milk
delivered to the door can still use the existing pint bottles, but milk
sold in shops is in SI.



   When I was a student, they told us, that in a couple of years there  
will be

the SI-system only, because most countries accepted it in their laws.
So we should adopt it.
That was in the early 70ties.
Only this year we have to deliver results of technical processes to  
british

and US companies. They still want them in their crazy outdated units.
  The other thing would be the US to adopt a simplified basic English.
I would not be astonished, that british people would state,
that they already do :-)





--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
class X(object):
def __int__(self): return 42
def __hex__(self): return '2b' #sic

hex(X())


What would you expect? Python2 returns '2b', but python 3(74624) throws
TypeError: 'X' object cannot be interpreted as an integer. Why doesn't
python convert the object to int before constructing the hex string?

Regards,

Philipp Hagemeister




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


Q on naming nested packages/modules

2009-09-01 Thread kj



I'm having a hard time getting the hang of Python's package/module
scheme.  I'd like to find out what's considered best practice when
dealing with the scenario illustrated below.

The quick description of the problem is: how can I have two nested
modules, spam.ham and spam.ham.eggs?

Suppose I have a module (I'm not even sure this is the right word)
called spam.ham, so I start out with the following file structure:

  spam/
  |-- ham.py
  `-- __init__.py

With this arrangement, the line

import spam.ham

...in client code works as expected.

But now suppose that I want to factor out some code in spam/ham.py
to a helper module.  (The reason behind factoring out this new
module is to declutter spam/ham.py, and improve its readibility.)
My instinct (from my Perl past) is to put this factored-out code
in a file spam/ham/eggs.py, i.e. to create the nested module
spam.ham.eggs, which requires expanding the tree as follows

  spam/
  |-- ham/
  |   |-- eggs.py
  |   `-- __init__.py
  |-- ham.py
  `-- __init__.py

...and adding the following spam/ham.py to

# spam/ham.py
from . import eggs

This doesn't work so well, because now spam/ham.py is not read.
It seems that adding the spam/ham directory, or maybe adding the
file spam/ham/__init__.py, causes spam/ham.py to be overlooked.


Clearly, I'm not playing this game right...

What is considered best practice for the use case sketched above?
Should I, e.g. rename the directory spam/ham something like spam/ham_
and refer to the helper module as spam.ham_.eggs?  Or is some other
convention preferred?

I consulted PEP 8, but besides recommending short, all-lowercase
names for modules, it gives little guidance on the situation
described above.

TIA!

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


Re: Permanently adding to the Python path in Ubuntu

2009-09-01 Thread David C. Ullrich
When I wanted to set PYTHONPATH I had the advantage of
knowing nothing about how Linux/Ubuntu was supposed to work,
so I tried everything. ~/.profile worked for me.

In article mailman.670.1251592772.2854.python-l...@python.org,
 Chris Colbert sccolb...@gmail.com wrote:

 I'm having an issue with sys.path on Ubuntu. I want some of my home
 built packages to overshadow the system packages. Namely, I have built
 numpy 1.3.0 from source with atlas support, and I need it to
 overshadow the system numpy 1.2.1 which I had to drag along as a
 dependency for other stuff. I have numpy 1.3.0 installed into
 /usr/local/lib/python2.6/dist-packages/. The issue is that this
 directory is added to the path after the
 /usr/lib/python2.6/dist-packages/ is added, so python doesnt see my
 version of numpy.
 
 I have been combating this with a line in my .bashrc file:
 
 export PYTHONPATH=/usr/local/lib/python2.6/dist-packages
 
 So when I start python from the shell, everything works fine.
 
 Problems show up when python is not executed from the shell, and thus
 the path variable is never exported. This can occur when I have
 launcher in the gnome panel or i'm executing from within wing-ide.
 
 Is there a way to fix this so that the local dist-packages is added to
 sys.path before the system directory ALWAYS? I can do this by editing
 site.py but I think it's kind of bad form to do it this way. I feel
 there has to be a way to do this without root privileges.
 
 Any ideas?
 
 Cheers,
 
 Chris

-- 
David C. Ullrich
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python3: hex() on arbitrary classes

2009-09-01 Thread Mark Dickinson
On Sep 1, 4:22 pm, Philipp Hagemeister phi...@phihag.de wrote:
 class X(object):
     def __int__(self): return 42
     def __hex__(self): return '2b' #sic

 hex(X())

 What would you expect? Python2 returns '2b', but python 3(74624) throws
 TypeError: 'X' object cannot be interpreted as an integer. Why doesn't
 python convert the object to int before constructing the hex string?

__hex__ is no longer a magic method in Python 3.  If you want to be
able to interpret instances of X as integers in the various Python
contexts that expect integers (e.g., hex(), but also things like list
indexing), you should implement the __index__ method:

Python 3.2a0 (py3k:74624, Sep  1 2009, 16:53:00)
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 class X:
... def __index__(self): return 3
...
 hex(X())
'0x3'
 range(10)[X()]
3
 'abc' * X()
'abcabcabc'

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


Re: Python3: hex() on arbitrary classes

2009-09-01 Thread Stephen Hansen
On Tue, Sep 1, 2009 at 8:22 AM, Philipp Hagemeister phi...@phihag.dewrote:

 class X(object):
def __int__(self): return 42
def __hex__(self): return '2b' #sic

 hex(X())


 What would you expect? Python2 returns '2b', but python 3(74624) throws
 TypeError: 'X' object cannot be interpreted as an integer. Why doesn't
 python convert the object to int before constructing the hex string?


The __oct__ and __hex__ special methods were removed in 3.0; instead, it
converts the value returned by __index__ in the appropriate base.

 class X:
def __index__(self):
return 42

 hex(X())
'0x2a'

The difference between __int__ and __index__ is that the former (when called
by int()) can convert a wide range of objects into an integer even if they
really /aren't/ -- like floats. There's some numbers you want to be able to
treat as int's sometimes, and those objects should define __int__... there's
other numbers which you really want to say, 'I _am_ an integer', those
should define __index__. Anything which defines __index__ can be used in
slicing.

At least that's my understanding. It's probably only half-right / flawed,
but :) The one part I'm sure of is in Python 3, there's no methods to
explicitly convert to a non-decimal base-- you define __index__ to return
the integer value and hex()/oct()/int(X,radix) convert it to the
appropriate base.

HTH,

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


Re: AttributeError: 'NoneType' object has no attribute 'get_text'

2009-09-01 Thread MRAB

Raji Seetharaman wrote:
Hi all, i worked out python and glade example program to add two numbers 
and display its output from the following link

http://www.dreamincode.net/forums/showtopic63885.htm
When i run the script, i received the following error

python add.py
Traceback (most recent call last):
  File add.py, line 34, in add
thistime = adder( self.wTree.get_widget(entryNumber1).get_text(), 
self.wTree.get_widget(entryNumber2).get_text())

AttributeError: 'NoneType' object has no attribute 'get_text'

What has to be done to overcome this error?


I think you need to name the text entry fields entryNumber1 and
entryNumber2.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
Mark Dickinson wrote:
 (...) If you want to be
 able to interpret instances of X as integers in the various Python
 contexts that expect integers (e.g., hex(), but also things like list
 indexing), you should implement the __index__ method:
Thanks. Somehow forgot this magic method and deleted it by accident.

Philipp
 
 Python 3.2a0 (py3k:74624, Sep  1 2009, 16:53:00)
 [GCC 4.3.2] on linux2
 Type help, copyright, credits or license for more information.
 class X:
 ... def __index__(self): return 3
 ...
 hex(X())
 '0x3'
 range(10)[X()]
 3
 'abc' * X()
 'abcabcabc'
 
 --
 Mark




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


Re: Q on naming nested packages/modules

2009-09-01 Thread Benjamin Kaplan
On Tue, Sep 1, 2009 at 11:58 AM, kjno.em...@please.post wrote:



 I'm having a hard time getting the hang of Python's package/module
 scheme.  I'd like to find out what's considered best practice when
 dealing with the scenario illustrated below.

 The quick description of the problem is: how can I have two nested
 modules, spam.ham and spam.ham.eggs?

 Suppose I have a module (I'm not even sure this is the right word)
 called spam.ham, so I start out with the following file structure:

  spam/
  |-- ham.py
  `-- __init__.py

 With this arrangement, the line

 import spam.ham

 ...in client code works as expected.

 But now suppose that I want to factor out some code in spam/ham.py
 to a helper module.  (The reason behind factoring out this new
 module is to declutter spam/ham.py, and improve its readibility.)
 My instinct (from my Perl past) is to put this factored-out code
 in a file spam/ham/eggs.py, i.e. to create the nested module
 spam.ham.eggs, which requires expanding the tree as follows

  spam/
  |-- ham/
  |   |-- eggs.py
  |   `-- __init__.py
  |-- ham.py
  `-- __init__.py

 ...and adding the following spam/ham.py to

 # spam/ham.py
 from . import eggs

 This doesn't work so well, because now spam/ham.py is not read.
 It seems that adding the spam/ham directory, or maybe adding the
 file spam/ham/__init__.py, causes spam/ham.py to be overlooked.


 Clearly, I'm not playing this game right...

 What is considered best practice for the use case sketched above?
 Should I, e.g. rename the directory spam/ham something like spam/ham_
 and refer to the helper module as spam.ham_.eggs?  Or is some other
 convention preferred?

 I consulted PEP 8, but besides recommending short, all-lowercase
 names for modules, it gives little guidance on the situation
 described above.


Take everything in ham.py and stick it in ham/__init__.py instead.
This will give you the behavior you're looking for (don't import
spam.ham.__init__. Everything in __init__.py is loaded into spam.ham)
 TIA!

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

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


Re: Q on naming nested packages/modules

2009-09-01 Thread kj
In h7jga8$ij...@reader1.panix.com kj no.em...@please.post writes:

I'm having a hard time getting the hang of Python's package/module
scheme.  I'd like to find out what's considered best practice when
dealing with the scenario illustrated below.

The quick description of the problem is: how can I have two nested
modules, spam.ham and spam.ham.eggs?

Following up my own post...

From inspecting the directory structure of some of the standard
Python modules I infer the following rules:

1. the source for leaf modules lives in files named after them
   (e.g. if x.y.z is a leaf module, its source code is in x/y/z.py)

2. the source for non-leaf modules lives in files named __init__.py
   (e.g. if x.y is a non-leaf module, its source code lives in
   the file x/y/__init__.py)

In the examples above, the module x.y is a non-leaf module because
there is a module x.y.z.

I.e. the leaf-ness of a module depends solely on whether other
modules deeper in the hierarchy are present.

An implication of all this is that if now I wanted to create a new
module x.y.z.w, this means that the previously leaf-module x.y.z
would become non-leaf.  In other words, I'd have to:

1. create the new directory x/y/z
2. *rename* the file x/y/z.py to x/y/z/__init__.py
3. create the file x/y/z/w.py to hold the source for the new x.y.z.w
   module

Is the above correct?  (BTW, to my Perl-pickled brain, step 2 above
is the one that causes most distress...  But I think I can cope.)

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


Re: Q on naming nested packages/modules

2009-09-01 Thread Ethan Furman

kj wrote:

In h7jga8$ij...@reader1.panix.com kj no.em...@please.post writes:



I'm having a hard time getting the hang of Python's package/module
scheme.  I'd like to find out what's considered best practice when
dealing with the scenario illustrated below.




The quick description of the problem is: how can I have two nested
modules, spam.ham and spam.ham.eggs?



Following up my own post...


From inspecting the directory structure of some of the standard

Python modules I infer the following rules:

1. the source for leaf modules lives in files named after them
   (e.g. if x.y.z is a leaf module, its source code is in x/y/z.py)

2. the source for non-leaf modules lives in files named __init__.py
   (e.g. if x.y is a non-leaf module, its source code lives in
   the file x/y/__init__.py)

In the examples above, the module x.y is a non-leaf module because
there is a module x.y.z.

I.e. the leaf-ness of a module depends solely on whether other
modules deeper in the hierarchy are present.

An implication of all this is that if now I wanted to create a new
module x.y.z.w, this means that the previously leaf-module x.y.z
would become non-leaf.  In other words, I'd have to:

1. create the new directory x/y/z
2. *rename* the file x/y/z.py to x/y/z/__init__.py
3. create the file x/y/z/w.py to hold the source for the new x.y.z.w
   module

Is the above correct?  (BTW, to my Perl-pickled brain, step 2 above
is the one that causes most distress...  But I think I can cope.)

kynn


Looking at the layout of the (most excellent!-) xlrd package, the bulk 
of the code is in the __init__.py file, and other supporting code is the 
 same directory, accessed in __init__ with normal imports.


I also am unclear on when it's best to have supporting files in the same 
directory versus a subdirectory... perhaps it is that flat is better 
than nested?


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


Re: Q on naming nested packages/modules

2009-09-01 Thread Carl Banks
On Sep 1, 8:58 am, kj no.em...@please.post wrote:
 I'm having a hard time getting the hang of Python's package/module
 scheme.  I'd like to find out what's considered best practice when
 dealing with the scenario illustrated below.

 The quick description of the problem is: how can I have two nested
 modules, spam.ham and spam.ham.eggs?

 Suppose I have a module (I'm not even sure this is the right word)
 called spam.ham, so I start out with the following file structure:

   spam/
   |-- ham.py
   `-- __init__.py

 With this arrangement, the line

 import spam.ham

 ...in client code works as expected.

 But now suppose that I want to factor out some code in spam/ham.py
 to a helper module.  (The reason behind factoring out this new
 module is to declutter spam/ham.py, and improve its readibility.)
 My instinct (from my Perl past) is to put this factored-out code
 in a file spam/ham/eggs.py, i.e. to create the nested module
 spam.ham.eggs, which requires expanding the tree as follows

   spam/
   |-- ham/
   |   |-- eggs.py
   |   `-- __init__.py
   |-- ham.py
   `-- __init__.py

 ...and adding the following spam/ham.py to

 # spam/ham.py
 from . import eggs

 This doesn't work so well, because now spam/ham.py is not read.
 It seems that adding the spam/ham directory, or maybe adding the
 file spam/ham/__init__.py, causes spam/ham.py to be overlooked.

There's a hint here.

You can move the contents of ham.py into ham/__init__.py, and it'll
work the way you want, maybe with only a minor change or two.


 Clearly, I'm not playing this game right...

 What is considered best practice for the use case sketched above?
 Should I, e.g. rename the directory spam/ham something like spam/ham_
 and refer to the helper module as spam.ham_.eggs?  Or is some other
 convention preferred?

The way you were intending is often the approach people use.  I doubt
there are any detailed consensus recommendations about this in the
Python community.


 I consulted PEP 8, but besides recommending short, all-lowercase
 names for modules, it gives little guidance on the situation
 described above.

Of course it doesn't, PEP 8 is a style guide, not a project
organization guide.


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


[ANN] doit: bringing the power of build-tools to execute any kind of task

2009-09-01 Thread schettino72
doit 0.3 released!

doit comes from the idea of bringing the power of build-tools to
execute any kind of task. It will keep track of dependencies between
tasks and execute them only when necessary. It was designed to be
easy to use and get out of your way.

http://pypi.python.org/pypi/doit/0.3.0
http://python-doit.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python word to text

2009-09-01 Thread BJörn Lindqvist
2009/9/1 Tino Wildenhain t...@wildenhain.de:
 Am 01.09.2009 13:42, schrieb Nitebirdz:

 On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJörn Lindqvist wrote:

 Hello everybody,

 I'm looking for a pure Python solution for converting word documents
 to text. App Engine doesn't allow external programs, which means that
 external programs like catdoc and antiword can't be used. Anyone know
 of any?


 A quick search returned this:

 http://code.activestate.com/recipes/279003/


 Did you give it a try?

 Thats a funny advice. Did you read that receipe? ;-)
 Requires the Python for Windows extensions, and MS Word.
 how does this match with App Engine doesn't allow external programs? :-)

 For excel this would be easy but word - Björn, did you check google api
 if you would be able to access google docs for this?

I did not, thanks for the tip! The system I managed to hack together
uploads the .doc to a google docs account and then retrieves it again
as plain text. It works but sure feels kind of silly. It's not very
reliable because if google has some kind of problem with their docs
application it doesn't work at all. Plus the method is dirt slow due
to the latency of all the http calls. But better than nothing.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is behavior of += intentional for int?

2009-09-01 Thread Piet van Oostrum
 zaur szp...@gmail.com (z) wrote:

z On 29 авг, 16:45, zaur szp...@gmail.com wrote:
 Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
 [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
 Type copyright, credits or license() for more information. a=1
  x=[a]
  id(a)==id(x[0])
 True
  a+=1
  a
 2
  x[0]
 
 1
 
 I thought that += should only change the value of the int object. But
 += create new.
 Is this intentional?

z As a result of this debate is not whether we should conclude that
z there should be two types of integers in python: 1) immutable numbers,
z which behave as constant value; 2) mutable numbers, which behave as
z variable value?

Numbers are immutable by nature (math). The number 3.14 remains 3.14
whatever you try to do with it. What you call an immutable number is in
fact a container that contains a number. You can change the contents of
the container, not by modifying the number in it but by replacing it
with a different number. Python has sufficient mechanisms for creating
these containers: lists, dictionaries, objects. If you think they are
not good enough then write a new one in C.
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Seeking a python code browser

2009-09-01 Thread Medi

Is there any recommendation for a python code browser (aka xref)
tool.
I am a Source Navigator user, but seems like its python support is
flaky. Unless you can help me with that...which is my preferred way.

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


Re: executable path finding

2009-09-01 Thread ryles
On Aug 31, 12:37 pm, koranthala koranth...@gmail.com wrote:
 On Aug 31, 9:07 pm, Diez B. Roggisch de...@nospam.web.de wrote:



  koranthala wrote:
   Hi,
       I am creating a python application using py2exe. I am facing a
   problem which I am not sure how to solve.
       The application contains many other files associated with it -
   like icons, config files etc. The executable can be in any directory.
   If the user creates a shortcut to the executable to run in desktop,
   the program fails - saying that the icon image cannot be found. But I
   can run the application properly, if I run it from application
   directory - where all the other icons, config files etc are kept.
       How is such issues usually solved? I do not want to hardcode the
   paths of icons and store the icons in those paths. I guess, we can
   change the directory to the application directory before running the
   application. (in __init__.py ???) But how do we find the current
   directory in that case? I am completely at sea in solving this.
       This looks to be a very common issue. How is this usually solved?

  You can get the location of a module via

   module.__file__

  This can be used to find a file relative to e.g. the toplevel module/package
  of your application.

  The pkg_resources-module of setuptools encapsulates that even into a stream
  and file-name api.

  Diez

 Thank you Diez. It was what I was looking for.

Also see:

http://docs.python.org/library/pkgutil.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python community buildbot page still 503

2009-09-01 Thread Martin v. Löwis
 If I am not mistaken http://python.org/dev/buildbot/community/all/ has
 been down since python.org had its harddrive issues.
 
 Anyone know a time line on getting it back up and running.

This service is, unfortunately, unmaintained. It broke when I upgraded
the buildbot master to a new code base, and nobody upgraded the buildbot
configuration file.

So I have now removed it from the web server configuration, and put a
notice on the web site.

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


Re: Why does this group have so much spam?

2009-09-01 Thread David
Il Tue, 1 Sep 2009 11:50:14 +0200, Andre Engels ha scritto:


 What about mailing lists? There exist well-functioning mailing lists
 with thousands of subscribers. Being a posting member of those will
 significantly increase your internet bill under your proposal.

It's an implementation issue, it doesn't touch the sense of proposal. 
One possibility is register the mail list to official registers and mail
from a subscriber to other subscribers will be excluded from taxation or
will have a lower tax rate.
An excessive mailing from a single or few subscribers can be easily
detected, traced, filtered and, if the case, prosecuted.

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


Re: An assessment of the Unicode standard

2009-09-01 Thread Hyuga
On Aug 29, 8:20 pm, John Machin sjmac...@lexicon.net wrote:
 On Aug 30, 8:46 am, r rt8...@gmail.com wrote:



  Take for instance the Chinese language with it's thousands of
  characters and BS, it's more of an art than a language.  Why do we
  need such complicated languages in this day and time. Many languages
  have been perfected, (although not perfect) far beyond that of Chinese
  language.

 The Chinese language is more widely spoken than English, is quite
 capable of expression in ASCII (r tongzhi shi sha gua) and doesn't
 have those pesky it's/its problems.

  The A-Z char set is flawless!

 ... for expressing the sounds of a very limited number of languages,
 and English is *NOT* one of those.

I'd say don't feel the troll, but too late for that I guess.  I just
wanted to add, in defense of the Chinese written language (in case
this hasn't already been added--I'm probably not going to bother
reading this entire thread) that I think it would make a fairly good
candidate for use at least as a universal *written* language.
Particularly simplified Chinese since, well, it's simpler.

The advantages are that the grammar is relatively simple, and it can
be used to illustrate concepts independently of the writer's spoken
language.  Sure it's tied somewhat to the Chinese language, but it can
certainly be mapped more easily to any other language than
phonetically-based written language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Q on naming nested packages/modules

2009-09-01 Thread Terry Reedy

kj wrote:



But now suppose that I want to factor out some code in spam/ham.py
to a helper module.  (The reason behind factoring out this new
module is to declutter spam/ham.py, and improve its readibility.)
My instinct (from my Perl past) is to put this factored-out code
in a file spam/ham/eggs.py, i.e. to create the nested module
spam.ham.eggs, which requires expanding the tree as follows

  spam/
  |-- ham/
  |   |-- eggs.py
  |   `-- __init__.py
  |-- ham.py
  `-- __init__.py

...and adding the following spam/ham.py to

# spam/ham.py
from . import eggs

This doesn't work so well, because now spam/ham.py is not read.
It seems that adding the spam/ham directory, or maybe adding the
file spam/ham/__init__.py, causes spam/ham.py to be overlooked.


Clearly, I'm not playing this game right...


One way is the __init__.py answer you have already. Another is to put 
eggs.py (or _eggs.py to indicate that it is private) in spam and skip 
the ham directory.


spam/
  __init__.py
  ham.py
  _eggs.py

tjr

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


Re: An assessment of the Unicode standard

2009-09-01 Thread r
On Sep 1, 2:39 am, Terry Reedy tjre...@udel.edu wrote:
(snip)
 There is, of course, an international system of measure. The US is the
 only major holdout. (I recall Burma, or somesuch, is another.) An
 interesting proposition would be for the US to adopt the metric system
 in exchange for the rest of the world adopting simplified basic English
 as a common language.


Bring on the metric system Terry, i have been waiting all my life!!

Now, if we can only convince those 800 million Mandarin Chinese
speakers... *ahem* Do we have a Chinese translator in the house?

:-)

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


Re: Q on naming nested packages/modules

2009-09-01 Thread Rami Chowdhury

An implication of all this is that if now I wanted to create a new
module x.y.z.w, this means that the previously leaf-module x.y.z
would become non-leaf.  In other words, I'd have to:

1. create the new directory x/y/z
2. *rename* the file x/y/z.py to x/y/z/__init__.py
3. create the file x/y/z/w.py to hold the source for the new x.y.z.w
   module


With regard to point 2 -- would it be possible to just move z.py into  
x/y/z, and put 'from z import *' into x/y/z/__init__.py, for the same  
effect? Or is that not a good idea?


On Tue, 01 Sep 2009 09:53:08 -0700, kj no.em...@please.post wrote:


In h7jga8$ij...@reader1.panix.com kj no.em...@please.post writes:


I'm having a hard time getting the hang of Python's package/module
scheme.  I'd like to find out what's considered best practice when
dealing with the scenario illustrated below.



The quick description of the problem is: how can I have two nested
modules, spam.ham and spam.ham.eggs?


Following up my own post...


From inspecting the directory structure of some of the standard

Python modules I infer the following rules:

1. the source for leaf modules lives in files named after them
   (e.g. if x.y.z is a leaf module, its source code is in x/y/z.py)

2. the source for non-leaf modules lives in files named __init__.py
   (e.g. if x.y is a non-leaf module, its source code lives in
   the file x/y/__init__.py)

In the examples above, the module x.y is a non-leaf module because
there is a module x.y.z.

I.e. the leaf-ness of a module depends solely on whether other
modules deeper in the hierarchy are present.

An implication of all this is that if now I wanted to create a new
module x.y.z.w, this means that the previously leaf-module x.y.z
would become non-leaf.  In other words, I'd have to:

1. create the new directory x/y/z
2. *rename* the file x/y/z.py to x/y/z/__init__.py
3. create the file x/y/z/w.py to hold the source for the new x.y.z.w
   module

Is the above correct?  (BTW, to my Perl-pickled brain, step 2 above
is the one that causes most distress...  But I think I can cope.)

kynn




--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: copy object?

2009-09-01 Thread Terry Reedy

lallous wrote:

Hello

I am new to python and have some questions.

How to copy objects using another method than this:

class op:
  def __init__(self, op):


What do you expect op to be? Certainly not the class 'op'.


for x in dir(op):
  if x[:2] == __:
continue
  setattr(self, x, getattr(op, x))

o = op(src)

I tried to copy with o = copy.copy(src) but as soon as src is
gone, o's attributes are not correct, and I cannot use copy.deepcopy
() because of this error:
TypeError: object.__new__(SwigPyObject) is not safe, use
SwigPyObject.__new__()

Can the previous for loop be simplified and replaced with a map() and
a lambda function?


If you want the instance to be a copy of another instance, the easier 
place to make the copy would be in the __new__ method, where you might 
be able to use copy.copy.


tjr

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


ANN: eGenix mxODBC - Python ODBC Database Interface 3.0.3

2009-09-01 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

eGenix.com mxODBC - Python ODBC Database Interface

  Version 3.0.3


   mxODBC is our commercially supported Python extension providing
ODBC database connectivity to Python applications
 on Windows and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mxODBC-3.0.3-GA.html



INTRODUCTION

mxODBC provides an easy-to-use, high-performance, reliable and robust
Python interface to ODBC compatible databases such as MS SQL Server,
MS Access, Oracle Database, IBM DB2 and Informix , Sybase ASE and
Sybase Anywhere, MySQL, PostgreSQL, SAP MaxDB and many more.

The eGenix mxODBC - Python ODBC Database Interface product is a
commercial extension to our open-source eGenix mx Base Distribution.

* About Python (http://www.python.org/):
Python is an object-oriented Open Source programming language which
runs on all modern platforms. By integrating ease-of-use, clarity in
coding, enterprise application connectivity and rapid application
design, Python establishes an ideal programming platform for
today's IT challenges.

* About eGenix (http://www.egenix.com/):
eGenix is a software project, consulting and product company focusing
on expert services and professional quality products for companies,
Python users and developers.



NEWS

mxODBC 3.0.3 is a patch-level release and includes the following updates:

* Python 2.3 - 2.6 support:

  mxODBC 3.0 is available for Python 2.3, 2.4, 2.5 and 2.6. We ship
  binaries for Windows, Linux, Mac OS X, AIX, Solaris, and offer
  custom porting services for most other platforms.

* Enhanced support for using cursors as iterators:

  mxODBC cursor objects can now be used as iterators to iterate over
  result sets. While this was already possible in previous versions
  using wrappers, we have now added direct iterator support to the
  cursor objects themselves.

* Updated work-arounds for various ODBC drivers:

  eGenix always aims to make using mxODBC as easy and robust as
  possible. For this reason, we regularly add or update work-arounds
  for problems found in recent ODBC driver versions.

  This release includes new work-arounds for the MySQL ODBC driver
  running on 64-bit Linux, the SQL Server 200 ODBC driver and the
  FileMaker ODBC driver.

For the full set of changes please check the mxODBC change log:

http://www.egenix.com/products/python/mxODBC/changelog.html

For the full set of features mxODBC has to offer, please see:

http://www.egenix.com/products/python/mxODBC/#Features



DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/mxODBC/

In order to use the eGenix mxODBC package you will first need to
install the eGenix mx Base package:

http://www.egenix.com/products/python/mxBase/



UPGRADING

You are encouraged to upgrade to this latest mxODBC release,
especially if you are using MS SQL Server or Informix as database
server.

Customers who have purchased mxODBC 3.0 licenses can download and
install this patch-level release on top of their existing
installations. The licenses will continue to work with version 3.0.2.

Users of mxODBC 2.0 will have to purchase new licenses from our online
shop in order to upgrade to mxODBC 3.0.2.

You can request 30-day evaluation licenses by visiting our web-site at

http://www.egenix.com/products/python/mxODBC/#Evaluation

or writing to sa...@egenix.com, stating your name (or the name of the
company) and the number of eval licenses that you need.

___

SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 01 2009)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 

Re: An assessment of the Unicode standard

2009-09-01 Thread Terry Reedy

r wrote:

On Sep 1, 2:39 am, Terry Reedy tjre...@udel.edu wrote:
(snip)

There is, of course, an international system of measure. The US is the
only major holdout. (I recall Burma, or somesuch, is another.) An
interesting proposition would be for the US to adopt the metric system
in exchange for the rest of the world adopting simplified basic English
as a common language.


as a common *second* language.



Bring on the metric system Terry, i have been waiting all my life!!

Now, if we can only convince those 800 million Mandarin Chinese
speakers... *ahem* Do we have a Chinese translator in the house?


They already pretty much are convinced as regards to English as a second 
language, which is what I meant.


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


Re: Python community buildbot page still 503

2009-09-01 Thread exarkun

On 07:27 pm, mar...@v.loewis.de wrote:
If I am not mistaken http://python.org/dev/buildbot/community/all/ 
has

been down since python.org had its harddrive issues.

Anyone know a time line on getting it back up and running.


This service is, unfortunately, unmaintained. It broke when I 
upgraded
the buildbot master to a new code base, and nobody upgraded the 
buildbot

configuration file.

So I have now removed it from the web server configuration, and put a
notice on the web site.


Um.  Where should I have been watching to get some warning about this?


Not sure. Looking at the waterfall pages of the buildbot would have
helped.

And now that I know, can you tell me what I need to do to restore it?


Are you in charge of it?


On reading your previous email, I assumed that someone (you, perhaps) 
had tried to contact Grig Gheorghiu (he was in charge of it last I 
heard) to let him know that some maintenance was required and that 
someone (you, perhaps) only made the decision to remove the community 
buildbots after he responded by indicating he was no longer willing to 
maintain it.


Since you're asking if I'm in charge of it, I'm now lead to believe that 
no one contacted Grig.  Is this the case?  In case it is, I'm cc'ing him 
on this email.

You need to fix the config file, remove the commented-out redirects in
the Apache configuration, and revert the two commits I did to the web
pages.


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


Re: Python community buildbot page still 503

2009-09-01 Thread Martin v. Löwis
 On reading your previous email, I assumed that someone (you, perhaps)
 had tried to contact Grig Gheorghiu (he was in charge of it last I
 heard) to let him know that some maintenance was required and that
 someone (you, perhaps) only made the decision to remove the community
 buildbots after he responded by indicating he was no longer willing to
 maintain it.

No, I immediately removed them when I learned that they were still
down, even though I broke them more than a month ago.

Of course, I didn't really remove them

 Since you're asking if I'm in charge of it, I'm now lead to believe that
 no one contacted Grig.  Is this the case?  In case it is, I'm cc'ing him
 on this email.

I sent a message to Grig right after I sent the other one, and he
already responded.

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


Re: Why does this group have so much spam?

2009-09-01 Thread David
Il Mon, 31 Aug 2009 20:06:54 -0700 (PDT), r ha scritto:

 Is the car owner not a victim too? :). i am ok with the filthy
 insurance company paying as long as the owners rates don't increase.

He is, unless he left keys in the cockpit, but he is 'less victim' of the
people involved in the accident. Since it is impossible to protect both kind
of victims the law protects the 'most victims'.

I'm not sure but I think that the increases.


 But why can't we force the criminal into hard labor to pay back the
 lost monies? Seems like that would serve justice to all parties...

I'm not saying that criminals shouldn't being prosecuted, but we are talking
of something else: creating and environment that discurages criminals,
because present enviroment is pretty wild and criminals have a big
advantage.
The mail-tax proposal aims to change this situation.

 That's a problem of the computer owner. Why should the rest of the world be
 charged of *his* problem while keeping him safe from suffering any
 consequence?
 
 No, why should spammers feel safe while doing their crimes? I say put
 the pressure on criminals, and NOT the victims. I really doubt much is
 being done to fight spam now that is why it is so prevalent. Two FBI
 hackers can't keep up with billions of spams.

This is a misunderstaning maybe caused by my poor english.
When a person gets his computer infected and becomes zombi machine, well,
*he* has a problem. At present, consequences of *his* problem are spread on
me, you, people reading this discussion and the rest of internet users,
while the infected computer's owner gets only a tiny fraction of those
consequences. 
He has no reason to check his computer periodically, clean it, being cautios
when surfing the net, do not install software to see free porn, etc etc
because he doesn't get an evident feedback of the damage he is (even
unconsciously) doing.

Do you really think that things should go in this way?

 Only if that tax was given to highly trained US Marines who where
 given a green light to use any and all methods to brutally kill the
 enemy and make an example of him with no worry of prosecution by their
 own government.

You did a mataphor and I've answered in the same metaphor. 
Let me say again that spammer and cyber criminal *must* be prosecuted with
all means, but we know that present environment helps bad guys instead of
good guys because most of the 'neutral guys' are just unaware (*and they
want remain unaware because it's comfortable*) of being used by bad guys.

 
 The mail-tax would be really small, if you send 1000 mails at month (a real
 huge traffic, for a non spammer!) the bill would be about 10 cents.
 Do you really think this is too much to get rid of most of the spam?
 
 I don't think that will stop most spammers since they must be making
 more that a 10c a month profit or they would starve to death! I say
 why not put a 1000.00 fine on any idiot that responds to a spam! What
 about that?

Spammers work with tenths of millions of mails/posts each month because they
get revenue only from a tiny fraction of them, about 1 over several
thousands.
The monthly cost for such a volume of traffic would be intolerable for them. 

 The system is definitely flawed. I am no internet expert so i don't
 really know what we could do to fix it. I do fear goverment or
 corporations taking over of the internet and robbing use of our
 freedom of speech under the pretense that they will *somehow* save us
 from the spammers. Something must be done however.

I definitely agree with you on that point, that's why I'm making this
proposal: the target is to reduce the spam *without* using armies of
cybercops patrolling all over the net. 
If we let the situation get worse, goverments will respond in the only way
they know: by restricting freedom.
At the opposite, if they realize that the problem is under control and even
they get a little revenue, they'll be happy to let us live in peace.
(I hope my english is correct enough to expose this concept...)


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


Re: Q on naming nested packages/modules

2009-09-01 Thread kj
In mailman.809.1251832870.2854.python-l...@python.org Rami Chowdhury 
rami.chowdh...@gmail.com writes:

 An implication of all this is that if now I wanted to create a new
 module x.y.z.w, this means that the previously leaf-module x.y.z
 would become non-leaf.  In other words, I'd have to:

 1. create the new directory x/y/z
 2. *rename* the file x/y/z.py to x/y/z/__init__.py
 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w
module

With regard to point 2 -- would it be possible to just move z.py into  
x/y/z, and put 'from z import *' into x/y/z/__init__.py, for the same  
effect? Or is that not a good idea?

I think in this case what you would need is something like 'from
..z import *', but this does not work either; one gets the error
SyntaxError: 'import *' not allowed with 'from .'.

A third solution would be to change step 2 above to this:

2. create the *symlink* x/y/z/__init__.py -- ../z.py 

This certainly would make things clearer-looking to me.  Having
all these files called the same thing, __init__.py, but having
completely different meaning, makes my head hurt...  In contrast,
the __init__.py *symlinks* would be there just to keep python happy;
the real content is where I'd expect it.

I ran a simple test of this idea and it works, but there may be
some subtle reasons for not doing it...  Or maybe it's not a good
idea simply because it is not the Python way, and I'd agree that
this would be reason enough to avoid it.

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


fastPATX Lion now out for your speedy web browsing needs!

2009-09-01 Thread patx
fastPATX Lion is now out! New features include, tabbed browsing, less
dependencies, and and a better download manager. The new version is by far
the most stable! There was only one crash recored in the fastPATX Lion-Alpha
testing! The bug that caused the crash has also been taking care of!
fastPATX was also reviewed and greatly liked by many others
(lmgtfy.com/?q=fastpatx).http://bitbucket.org/patx/fastpatx/downloads/fastpatx-lion.py

get fastpatx herehttp://bitbucket.org/patx/fastpatx/downloads/fastpatx-lion.py

-- 
patx, python gui and web, http://patx.me
-- 
http://mail.python.org/mailman/listinfo/python-list


port of GWTCanvas to python / pyjamas

2009-09-01 Thread lkcl
as part of the recent porting of GGhart to pyjamas, a massive
performance gain can be had by using SVG Canvas.  unfortunately, that
meant porting GWTCanvas to pyjamas as well.  this is also progressing
well:
http://pyjs.org/examples/gwtcanvas/

if anyone would like to help with the porting effort and with testing,
that would be great: please contact pyjamas-...@groups.google.com.
the IE engine uses VML, and the GWTCanvas library takes care of
providing an SVG-like interface to VML (which is rather cool).

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


Re: port of GWT GChart to python pyjamas

2009-09-01 Thread lkcl
 been ported already, enough to show that the libray is in a mostly
 useable state, even after only three days.  pie-charts are proving
 slightly problematic (as GChartExample24, which is a pie chart editor,
 shows).

fixed.  demo at : 
http://pyjs.org/examples/gcharttestapp/output/GChartTestApp.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread r
On Sep 1, 1:52 pm, Hyuga hyugaricd...@gmail.com wrote:
(snip)
 I'd say don't feel the troll, but too late for that I guess.  

The only trolls in this thread are you and the others who breaks into
MY THREAD just for the knee-jerk reaction of troll calling! Even
though you *did* offer some argument to one of the subjects of this
thread, it was cancelled out by your trolling!

Please come back when you have some constructive thoughts on the
subjects of Python as it relates to Unicode, or Universal natural
languages. Whether you want to admit it or not these subjects affect
programming and Python.

And here is the definition of a troll for the uneducated among us, of
which it seems is surprising a very large number these days...
http://en.wikipedia.org/wiki/Troll_(Internet)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is behavior of += intentional for int?

2009-09-01 Thread Steven D'Aprano
On Tue, 01 Sep 2009 07:04:09 -0700, zaur wrote:

 On 1 сен, 03:31, Steven D'Aprano st...@remove-this- cybersource.com.au
 wrote:
 On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote:
  As a result of this debate is not whether we should conclude that
  there should be two types of integers in python: 1) immutable
  numbers, which behave as constant value; 2) mutable numbers, which
  behave as variable value?

 What can you do with mutable numbers that you can't do with immutable
 ones, and why do you want to do it?

 --
 Steven
 
 Mutable numbers acts as variable quantity. 

So do immutable numbers bound to a name.


 So when augmented assignment
 is used there is no need to create a new number object in every binary
 operation.

No need, sure, but there's no *need* to use object oriented code in the 
first place, or garbage collectors, or high level languages, or even 
functions. People got by with GOTO and assembly for years :) We use all 
these things because they make *programming* easier, even if it adds 
runtime overhead.

I'm asking what *problem* you are trying to solve with mutable numbers, 
where immutable numbers are not satisfactory. The only answer I can 
imagine is that you're worried about the overhead of creating new integer 
objects instead of just flipping a few bits in an existing integer 
variable.


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


Re: An assessment of the Unicode standard

2009-09-01 Thread Rami Chowdhury

The only trolls in this thread are you and the others who breaks into
MY THREAD just for the knee-jerk reaction of troll calling!


How does this make one's opinion any less relevant? I think the fact that  
you are coming across in this thread as closed-minded, bigoted, and  
uninformed gives everyone plenty of right to accuse you of trolling. Being  
aggressive about it doesn't help.


Yes, Unicode is a hack, but it's a hack necessitated by the prevalence  
(and naivete) of ASCII. If you're advocating something as absurd as  
standardizing on a universal, simple language, how about an almost equally  
ridiculous proposal: why don't we break backwards-compatibility with ASCII?


--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-01 Thread Steven D'Aprano
On Tue, 01 Sep 2009 08:35:46 -0700, Rami Chowdhury wrote:

 SI is preferred,
 but Imperial is permitted.
 
 IME most people in the UK under the age of 40 can speak SI without
 trouble.
 
 On the other hand, let's nip down to the pub for 580ml of beer just
 doesn't have the right ring to it ;-)


Oh those wacky Brits and their obsession with precision -- why do they 
have to specify the volume of beer? What's wrong with any of these?

Let's nip down to the pub for a beer.

Let's nip down to the pub for a couple of drinks.

Let's nip down to the pub -- good for drinkers who prefer a brandy.

Let's go get hammered! -- what they're really thinking.



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


Re: An assessment of the Unicode standard

2009-09-01 Thread r
On Sep 1, 6:06 pm, Rami Chowdhury rami.chowdh...@gmail.com wrote:
(snip: trolling tirade)

I don't think when i started this thread i had any intentions what-so-
ever of pleasing asinine-anthropologist, sociology-sickos, or neo-nazi-
linguist. No, actually i am quite sure of that is the case!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-01 Thread Terry Reedy

David wrote:


I'm not saying that criminals shouldn't being prosecuted, but we are talking
of something else: creating and environment that discurages criminals,
because present enviroment is pretty wild and criminals have a big
advantage.
The mail-tax proposal aims to change this situation.


I have read at least one person saying he did not mind his machine being 
used to send out spam. I have read more that one person advocating 
leaving one's wi-fi base open for anyone to use as the 'neighborly' 
thing to do.


A substantial fraction of people have turned off Window's update. 
Consequently, whenever Microsoft announces a vulnerablility and patch, 
malware writers can write an exploit of the announced vulnerability and 
be sure that they will find vulnerable machines.


All the above are contributors to the problem and are externalizing some 
of the proper cost of ownership and operation of a net-connected computer.


tjr

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


Re: Is behavior of += intentional for int?

2009-09-01 Thread Carl Banks
On Sep 1, 10:40 am, Piet van Oostrum p...@cs.uu.nl wrote:
  zaur szp...@gmail.com (z) wrote:
 z On 29 авг, 16:45, zaur szp...@gmail.com wrote:
  Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
  [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
  Type copyright, credits or license() for more information. a=1
   x=[a]
   id(a)==id(x[0])
  True
   a+=1
   a
  2
   x[0]

  1

  I thought that += should only change the value of the int object. But
  += create new.
  Is this intentional?
 z As a result of this debate is not whether we should conclude that
 z there should be two types of integers in python: 1) immutable numbers,
 z which behave as constant value; 2) mutable numbers, which behave as
 z variable value?

 Numbers are immutable by nature (math). The number 3.14 remains 3.14
 whatever you try to do with it. What you call an immutable number is in
 fact a container that contains a number.

I wouldn't agree with that terminology or logic.

First of all mutable number is really just a short way to say
mutable number object.  A number object in Python is not a number,
it's just a representation of a number.  Even if numbers are immutable
by nature, an object representing a number need not be.

And if your number object is mutable, it does not make that object a
container, at least not what I would call a container.  A container
you have to dereference somehow to get at the object inside, whereas a
mutable number object you don't dereference: it acts like number as-
is.

IOW, the first example below is a container, the second is not:

num = [2]
num[0] += 3

num = mutable_int(2)
num += 3

(If you want to call the mutable number a container anyway, fine with
me, I am not here to bicker.)  A container is sufficient to get a
layer of indirection if that's what you want the mutable number for.

However, the mutable number has a performance advantage over using a
container: it avoids the overhead of creating a new object.  If you
were using += in a loop like this, it could turn out to be significant
savings.  But since that's not common in Python I'd have to agree that
this optimization opportunity is best done with a third-party C-
extension, and not the standard library.


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


Re: An assessment of the Unicode standard

2009-09-01 Thread Rami Chowdhury

On Tue, 01 Sep 2009 16:29:54 -0700, r rt8...@gmail.com wrote:


[snip: variety of almost-alliterative epithets]


Well, if you admit you set out to offend people, then you're trolling.



--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is behavior of += intentional for int?

2009-09-01 Thread Terry Reedy

Steven D'Aprano wrote:


I'm asking what *problem* you are trying to solve with mutable numbers, 
where immutable numbers are not satisfactory. The only answer I can 
imagine is that you're worried about the overhead of creating new integer 
objects instead of just flipping a few bits in an existing integer 
variable.


Of course, *because ints are immutable*, an implementation can avoid the 
overhead of object creation for common cases by creating an array of 
small integers.


CPython currently does this for -10 (or -5?) to about 256 or 257. I 
would not be surprised if this coevers at least 80% of int.__new__ requests.


tjr

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


python module for data comparison of 2 MySQL servers

2009-09-01 Thread none

I have 2 MySQL servers in 2 different data centers.
Between them, there is data replication setup.

Is there a python tool so I can do data comparison for daily records?

Basically, just access both servers and do a diff in memory and print 
out records.


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


Re: Why does this group have so much spam?

2009-09-01 Thread Steven D'Aprano
On Tue, 01 Sep 2009 20:48:19 +0200, David wrote:

 Il Tue, 1 Sep 2009 11:50:14 +0200, Andre Engels ha scritto:
 
 
 What about mailing lists? There exist well-functioning mailing lists
 with thousands of subscribers. Being a posting member of those will
 significantly increase your internet bill under your proposal.
 
 It's an implementation issue, it doesn't touch the sense of proposal.
 One possibility is register the mail list to official registers and mail
 from a subscriber to other subscribers will be excluded from taxation or
 will have a lower tax rate.
 An excessive mailing from a single or few subscribers can be easily
 detected, traced, filtered and, if the case, prosecuted.

This can be done already, without the need for an email tax. ISPs could 
easily detect spammers, if they cared to.

There are a few things that can already be done to cut the spam problem 
to manageable size:

(1) Why aren't ISPs blocking port 25 for home users by default? My home 
ISP does, I can only send email through their mail server unless I ask 
them nicely, in which case I'd be responsible for any spam that leaves my 
home network. If I send spam, I'll be breaking my terms of service.

(2) Why aren't ISPs cutting off detected spam bots? Owners of zombied PCs 
are menaces to society. ISPs are in the best position to detect PCs which 
are spamming, and alert the owner. If no action is taken in a week, warn 
the owner that they're in breach of their terms of service, and if the 
behaviour persists, cut the owner off until they clean up their PC. 
Repeat offenders should be banned.

(3) ISPs who won't cut off spam bots are either incompetent or have a 
financial incentive to do business with spammers. Therefore, responsible 
ISPs should cut them off. If this means the email universe divides into 
two halves, the Wild West where 999 emails out of every 1000 are spam, 
and Civilization where only one in a thousand is spam, I'm okay with that.

As for the argument that home users who send spam are the victim, that's 
true up to a point, but not very far. Here's an analogy: suppose that 
terrorists sneak into your house after picking the lock -- or in the case 
of Windows users with no firewall or anti-malware, stroll through the 
unlocked front door -- and spend the next six months camped in your spare 
bedroom, using your home for their base of operations while they make 
terrorist attacks. When the FBI kicks your doors down, don't you think 
you would be arrested and would have to prove that you couldn't be 
reasonably expected to know they were there? If millions of spam emails 
are coming out of your PC, that's prima facie evidence that YOU are 
spamming. You would need to prove that you're an innocent victim who 
couldn't *reasonably* be expected to know that your machine was hijacked 
-- you would need to prove that the spam bot was so sophisticated that it 
infected your PC despite the firewall, that you didn't install it 
yourself in order to get some stupid game, that no commonly available 
anti-malware program detects it. Anything less than that is *at least* 
negligence, and possibly willful negligence.

Negligence is a crime too, especially willful negligence. Perhaps a 
lesser crime than deliberate bad behaviour, but if you kill somebody 
because you neglected to service your car, the argument I'm the victim 
here, blame somebody else! wouldn't get you very far. Not knowing how to 
service your car to keep it in good working order is not an excuse -- if 
you don't know how to change the brakes, there are people who do. If you 
don't know how to set up an effective firewall and anti-malware software, 
there are people who do. Stop hiding behind your ignorance, and pay an 
expert to service -- and secure -- your computer. It is 2009, and the 
malware problem isn't some theoretical threat that only a handful of 
people know about. Anyone with an infected PC who does nothing about it 
is, in my opinion, *equally* responsible for the spam being sent out as 
the criminals who hijacked the PC in the first place.

Yes, I'd like to see the criminals, the malware authors and the spammers 
punished, but I'd be satisfied to see them put out of business. The weak 
link is the zombie PCs -- fix the home users' PCs, or block them, take 
them off the Internet, and spam becomes manageable again.



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


Re: Overriding iadd for dictionary like objects

2009-09-01 Thread RunThePun
On Sep 1, 3:00 am, a...@pythoncraft.com (Aahz) wrote:
 In article 
 b11a8a0e-03ca-41c9-b0d0-c5180b6a2...@p15g2000vbl.googlegroups.com,





 RunThePun  ubershme...@gmail.com wrote:
 On Aug 30, 10:33=A0pm, a...@pythoncraft.com (Aahz) wrote:
  In article e09276e8-8152-4002-8366-4c12705a8...@l35g2000vba.googlegroups=
 .com,
  RunThePun =A0ubershme...@gmail.com wrote:

 I made a DictMixin where the keys are filenames and the values are the
 file contents. It was very simple and easy to do thanks to DictMixin.

 For example this code writes abc in a file named temp.txt and
 prints the contents of the file named swallow, these files are
 looked up/created/deleted in the directory spam:
  d =3D3D FilesDict('spam')
  d['temp.txt'] =3D3D 'abc'
  print(d['swallow'])

 My problem arose when I wanted to append a string to a file which
 using open(..., 'ab') would have been miles more efficient because I
 wouldn't have to read the entire file (__getitem__) and then write the
 entire file back (__setitem__). The files are expected to be as big as
 600 KB which will be appended 30 bytes at a time about 3 times a
 second. Performance-wise the system would probably work without open
 (..., 'ab') but it would be a real thrashing so the current solution
 uses a method AddTo as Robert suggested, sacrificing the neat
 getitem/setitem syntax.

  You can do mostly what you want, I think, by having __setitem__()
  convert string values into FileProxy() objects that have an appropriate
  __iadd__() method. =A0That brings a whole new set of problems, of course.

 I'm guessing you meant __getitem__, which is what Jan Kaliszewski
 suggested, but as you noted, would be a bit cumbersome in this case.

 Actually, what I meant was __setitem__.  The idea is that you create the
 proxy item when you add the data to the dict (wrapping the original
 data), and the proxy has an __iadd__ method, which would allow you to do
 the file append.
 --
 Aahz (a...@pythoncraft.com)           *        http://www.pythoncraft.com/

 I support family values -- Addams family values --www.nancybuttons.com

But you do mean that __getitem__ would return a wrapped object as
well, right? Otherwise I don't see how the iadd would be relevant
because:
   d['a'] += 3
is equivalent to:
   d.__setitem__('a', d.__getitem__('a').__iadd__(3))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK problems after Linux update...

2009-09-01 Thread barcaroller

barcaroller barcarol...@music.net wrote in message
news:h7ev9g$dc...@news.eternal-september.org...

 Okay, I won't disagree, but how do I fix this?

Never mind.  The latest update today included a new pygtk
which seems to have fixed the problem.  All is good now.



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


  1   2   >