Wing IDE 4.1.12 released

2013-03-09 Thread Wingware

Hi,

Wingware has released version 4.1.12 of Wing IDE, our integrated development
environment designed specifically for the Python programming language.

Wing IDE provides a professional quality code editor with vi, emacs, and 
other
key bindings, auto-completion, call tips, refactoring, context-aware 
auto-editing,
a powerful graphical debugger, version control, unit testing, search, 
and many

other features.  For details see http://wingware.com/

This minor release includes:

* Support for Python 2.6 and 2.7 running on cygwin
* List SHA1 hashes on the downloads page
* Show perspectives key bindings in Load Perspective sub-menu
* Fix several color-related regressions
* Fix extract refactoring when toplevel source is indented
* Return focus to editor after refactoring operations
* 6 other bug fixes and minor improvements

For a complete change log see 
http://wingware.com/pub/wingide/4.1.12/CHANGELOG.txt


Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature matrix: http://wingware.com/wingide/features
More information: http://wingware.com/
Sales: http://wingware.com/store/purchase
Upgrades: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at sa...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com

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

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


Re: An error when i switched from python v2.6.6 = v3.2.3

2013-03-09 Thread Νίκος Γκρ33κ
Τη Σάββατο, 9 Μαρτίου 2013 7:05:08 π.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε:
 On Fri, 08 Mar 2013 19:18:50 -0800, Νίκος Γκρ33κ wrote:
 
 
 
  I agree with you but i wonder why the world would want to dedicate hours
 
  for fiddling with my script? Why anyone should mess with my website
 
  http://superhost.gr ?
 
 
 
 
 
 What makes you think it would be hours? For somebody who knows what they 
 
 are doing, it is probably more like minutes.
 
 
 
 And as for why...
 
 
 
 - because they think it's funny;
 
 
 
 - because they get pleasure from vandalising other people's property;
 
 
 
 - to prove that they can do it;
 
 
 
 - to punish you for being naive and foolish;
 
 
 
 - to get control of your webserver, so they can store files on it without 
 
 your knowledge;
 
 
 
 - or launch attacks on other people's websites;
 
 
 
 - or to encrypt your data and charge you money to decrypt it;
 
 
 
 - or some other reason that I cannot think of.
 
 
 
 
 
 
 
 -- 
 
 Steven

I see, didn think of those reason apart form the fact that they cna prove they 
can do it!

But as i have it now more security improved they can't :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running external module and accessing the created objects

2013-03-09 Thread Steven D'Aprano
On Fri, 08 Mar 2013 22:06:28 -0500, Kene Meniru wrote:

 Program summary:
 
 I have a module called user.py that imports another module called
 app.py. Functions in app.py are used in user.py to describe 3D objects.
 These objects are saved in another object described in doc.py.

What do you mean, objects are saved in another object?


 app.py contains a function called view(). When called in user.py, it
 signals the end of object descriptions. Presently all objects contained
 in doc.py are exported to either POV-Ray or OpenSCAD file format
 depending on the argument given to view().
 
 My Issues:
 
 I have decided I want to provide a preview of the objects using opengl
 (pyglet). So I am trying to create another module called appwin.py which
 the user can launch with user.py as an argument.

What happens if the user launches appwin with a different argument?

If appwin can only take one, compulsory, argument, then it's silly to 
require it as an argument. Just have appwin automatically import user.py, 
and do whatever it needs.


 When each object is
 described in user.py, I want the user to be able to switch to appwin.py,
 provide a signal that makes appwin.py redraw the screen to show any
 modifications (perhaps with the enter key).

This makes no sense to me. Are you saying that appwin opens a text editor 
that allows the user to edit the user.py source code?


 I do not want to invest much time with appwin.py now as I am still
 coding app.py. Right now, appwin.py just subclasses
 pyglet.window.Window().
 
 I do not want to merge app.py and appwin.py. I want them to be two
 separate applications because I want to retain the option of either
 console or many different window interfaces.

Making them a single module still retains the option of console or many 
different window interfaces.


 The problem then is:
 
 How can I run appwin.py which will then execute user.py to create the
 objects to be saved in doc.py. 

I don't know. How does user.py create the objects? Suppose it users a 
function called create. Then you would do this in appwin:


import user
user.create()


 Then when view() is encountered to be
 able to access the objects stored in doc.py in appwin.py?

What do you mean by view() is encounted? 

How would you access the objects stored in doc.py? Suppose you access 
them using a list called list_of_objects. Then in appwin.py:

import doc
for obj in doc.list_of_objects:
do_something_with(obj)

where you have to write the function do_something_with, to do whatever 
it is you want to do.


By the way, calling a module doc which is not for *documentation* is a 
bad idea.



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


RE: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Wong Wah Meng-R32813


If the memory usage is continually growing, you have something else 
that is a problem -- something is holding onto objects. Even if Python is not 
returning memory to the OS, it should be reusing the memory it has if objects 
are being freed.
-- 
[] Yes I have verified my python application is reusing the memory (just that 
it doesn't reduce once it has grown) and my python process doesn't have any 
issue to run even though it is seen taking up more than 2G in footprint. My 
problem is capacity planning on the server whereby since my python process 
doesn't release memory back to the OS, the OS wasn't able to allocate memory 
when a new process is spawn off.   

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


Re: Apparent magic number problem

2013-03-09 Thread Peter Otten
Colin J. Williams wrote:
 The program runs correctly under each version, but it runs more slowly 
 under 3.2.

 This is probably due to the fact that the .pyc file is created for the
 Python 2.7 execution.
 
 When Python 3.2 is run it fails to create a new .pyc file and if the 2.7
 .pyc is offered directly a magic number problem is reported.

(1) .pyc files are only created if a module is imported
(2) The 2.7 .pyc file is put alongside the .py file whereas the 3.2 .pyc is 
put into the __pycache__ subfolder. No clash can occur.

A simple example:

$ ls
mod.py
$ cat mod.py
print(hello world)

Run it; no pyc is created:

$ python2.7 mod.py
hello world
$ ls
mod.py

Import it using 2.7:

$ python2.7 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc

Import it using 3.2:

$ python3.2 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc  __pycache__
$ ls __pycache__/
mod.cpython-32.pyc

Run the compiled code:

$ python2.7 mod.pyc
hello world
$ python3.2 __pycache__/mod.cpython-32.pyc 
hello world

But I'm with Steven, it's unlikely that the module compilation phase is 
responsible for a noticeable slowdown.


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


Trelby (was: Any other screenwriters?)

2013-03-09 Thread W. Martin Borgert
On 2013-03-08 13:07, Rick Dooling wrote:
 However, most of these programs are apps with closed GUIs, and of course 
 I'm looking for a way to do the same thing with Python and call it from the 
 command-line or from within Vim

You should consider taking a look at Trelby. It is free software
(GPL2) and written in Python. While it is a GUI program, you can
import (txt, fdx, celtx, astx, fountain, fadein) and export (pdf,
rtf, fdx, html, foutain, txt), so using vi for editing should
just work. I have no practical experience with the program,
however. If you try it, you should probably take a snapshot from
github, not the latest release 2.2, because it seems, they fixed
some installation issues. While I have no experience in
screenwriting yet, the program seems to run fine for me on
Debian Linux. Find Trelby here: http://www.trelby.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Dave Angel

On 03/09/2013 03:07 AM, Wong Wah Meng-R32813 wrote:



 Yes I have verified my python application is reusing the memory (just that it 
doesn't reduce once it has grown) and my python process doesn't have any issue to 
run even though it is seen taking up more than 2G in footprint. My problem is 
capacity planning on the server whereby since my python process doesn't release 
memory back to the OS, the OS wasn't able to allocate memory when a new process is 
spawn off


So is the server running out of disk space?  If not, why not increase 
the swapfile(s) size?  That's what's being held onto, not RAM.


If you are short on disk space, and therefore cannot afford to increase 
the swapfile size, then you may want to plan the Python program's 
execution around that constraint.


Discounting the play-program that started this thread, is it possible 
that your actual app unnecessarily uses lots of space during one phase 
of execution, and therefore is saddled with that space at other times? 
For example, are you using a large list to hold a data file when an 
iterator would do just as well?


If that phase of execution cannot be eliminated, but it's a fleeting 
time, perhaps that part of the execution can be launched from the main 
app as a separate process.  When the process ends, the memory is freed.


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


Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Steven D'Aprano wrote:


 What do you mean, objects are saved in another object?


doc.py has a dictionary. When the user describes a wall, it is passed 
to the doc object to be saved in the dictionary. 
 
 
 What happens if the user launches appwin with a different argument?
 
 If appwin can only take one, compulsory, argument, then it's silly 
to
 require it as an argument. Just have appwin automatically import 
user.py,
 and do whatever it needs.
 

I guess my description does not come across well.

I thought user.py sounded like it is, a user created file. It will be 
named differently for each user to created different types of 3D 
objects. It does not make sense to expect every user to name their 
design file the same. So there will have to be a differently named 
single argument for buildeswin.

 
 This makes no sense to me. Are you saying that appwin opens a text 
editor
 that allows the user to edit the user.py source code?
 

No. appwin opens an opengl (pyglet.window.Window()) graphics window as 
I mentioned.

 
 I don't know. How does user.py create the objects? Suppose it users 
a
 function called create. Then you would do this in appwin:
 
 
 import user
 user.create()
 

I have tried importing user.py and/or app.py. However there is no 
single command to call.

My program is designed to assist in the building design process. It is 
a big program and the creation of building components takes quite a 
few steps. I do not want to support these steps in a graphics window 
which is why the user uses any text editor they prefer to create 
user.py. I want appwin.py (which has a graphics window) to be able 
to access objects stored in doc.py (which has a dictionary) after a 
command like python user.py so that the objects saved in doc.py 
after execution can be retrieved and drawn in appwin.py.

 What do you mean by view() is encounted?


This is a command that the user can enter in user.py. app.py will then 
encounter this command as python parses the file.
 
 How would you access the objects stored in doc.py? Suppose you 
access
 them using a list called list_of_objects. Then in appwin.py:
 
 import doc
 for obj in doc.list_of_objects:
 do_something_with(obj)
 

I have tried this but there are no objects found in the dictionary in 
doc.py. I am guessing that I have to execute appwin.py so that it 
shares the same namespace with user.py or maybe a way to access that 
namespace. This is the reason for my question.

 where you have to write the function do_something_with, to do 
whatever
 it is you want to do.
 
 
 

-- 

Kene
::
kemen...@gmail.com

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Chris Angelico
On Sat, Mar 9, 2013 at 10:05 PM, Kene Meniru kene.men...@illom.org wrote:
 I have tried importing user.py and/or app.py. However there is no
 single command to call.

I haven't followed the thread in detail, but I gather you're trying to
import a file with a variable name? Instead of 'import user', try:

user = __import__(foobar)

You can then replace the quoted string with whatever you need (note,
leave off the .py extension). In your code, it'll be as if you did:

import foobar as user

but with the flexibility of using whatever run-time-chosen name you need.

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Dave Angel

On 03/09/2013 06:05 AM, Kene Meniru wrote:


  (lots of stuff that was more confusing to me than helpful)


You use the words launch, encountered, execute, and others in ways that 
do not make sense to me, or are at least ambiguous.


You have an explicitly named user.py, which apparently is *not* 
generally named that.


I could give you lots of random facts and suggestions, and one of the 
might hit home.  For example the __import__() function can import a 
module that you don't know the name of ahead of time.  It's not often 
the right answer, though, so I hesitate to suggest it.


For another example, if you import a module by two different names, or 
if you import the module that is your starting script, then you can 
end up with two instances of such a module, with all sorts of negative 
implications about global data or class attributes stored in that 
module, or even more subtle problems.


For a final example, having a circular import tree can cause problems if 
any of those imports have any global code (like class initialization, 
defining constants, etc.).  It's generally much better to define a 
strict hierarchy of who imports whom.


But I think instead that it'd be better for you to make a clearer 
statement about how your code is structured.


I'm guessing that all of this is intended to be in one executable -- no 
child processes, etc.  So don't say launch, say import, or 
function-call, or whatever you are really doing.


I'm guessing that you're running this on Python 3.3 under Linux.

I'm guessing that user.py is one possible name that a particular user 
calls his script.  And that script is what he runs on the Python 
commandline.


python user.py

And that script calls functions in app.py, doc.py, and/or appwin.py. 
And that currently, you're trying to import user.py from one of your own 
modules, for purposes of either callback functions or global data 
access.  That's a mistake.  When you import your *script* (using 
__import__() as suggested above) you get a new copy of the script, and 
new copies of all its global data.


I can't even guess how you're intending to mix the commandline stuff of 
app.py with gui stuff in one or more appwin.py variants.  You'll have to 
be explicit, if it even matters yet.


I suggest that rather than responding to these points, you restate your 
problem, in one place, with coherent detail that eliminates these 
guesses and replaces them with reality.  Start with the environment this 
is running in, and the commandline typically used to launch the code, 
and the interdepencies of the various modules.




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


Re: An error when i switched from python v2.6.6 = v3.2.3

2013-03-09 Thread Mark Lawrence

On 09/03/2013 07:56, Νίκος Γκρ33κ wrote:

Τη Σάββατο, 9 Μαρτίου 2013 7:05:08 π.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε:

On Fri, 08 Mar 2013 19:18:50 -0800, Νίκος Γκρ33κ wrote:




I agree with you but i wonder why the world would want to dedicate hours



for fiddling with my script? Why anyone should mess with my website



http://superhost.gr ?






What makes you think it would be hours? For somebody who knows what they

are doing, it is probably more like minutes.



And as for why...



- because they think it's funny;



- because they get pleasure from vandalising other people's property;



- to prove that they can do it;



- to punish you for being naive and foolish;



- to get control of your webserver, so they can store files on it without

your knowledge;



- or launch attacks on other people's websites;



- or to encrypt your data and charge you money to decrypt it;



- or some other reason that I cannot think of.







--

Steven


I see, didn think of those reason apart form the fact that they cna prove they 
can do it!

But as i have it now more security improved they can't :-)



Red flag to a bull.

Would you also please read section 2 of this 
http://wiki.python.org/moin/GoogleGroupsPython to prevent all of your 
posts having quotean excessive number of quoted blank lines./quote


--
Cheers.

Mark Lawrence

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


Re: An error when i switched from python v2.6.6 = v3.2.3

2013-03-09 Thread Νίκος Γκρ33κ
Is there a way to see anserws to my posts via ThunderBird that doesn't hve this 
formatting issue?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Isaac To
In general, it is hard for any process to return the memory the OS allocate
to it back to the OS, short of exiting the whole process.  The only case
that this works reliably is when the process allocates a chunk of memory by
mmap (which is chosen by libc if it malloc or calloc a large chunk of
memory), and that whole chunk is not needed any more.  In that case the
process can munmap it.  Evidently you are not see that in your program.
What you allocate might be too small (so libc choose to allocate it using
another system call sbrk), or that the allocated memory also hold other
objects not freed.

If you want to reduce the footprint of a long running program that
periodically allocates a large chunk of memory, the easiest solution is
to fork a different process to achieve the computations that needs the
memory.  That way, you can exit the process after you complete the
computation, and at that point all memory allocated to it is guaranteed to
be freed to the OS.

Modules like multiprocessing probably make the idea sufficiently easy to
implement.


On Sat, Mar 9, 2013 at 4:07 PM, Wong Wah Meng-R32813
r32...@freescale.comwrote:



 If the memory usage is continually growing, you have something
 else that is a problem -- something is holding onto objects. Even if Python
 is not returning memory to the OS, it should be reusing the memory it has
 if objects are being freed.
 --
 [] Yes I have verified my python application is reusing the memory (just
 that it doesn't reduce once it has grown) and my python process doesn't
 have any issue to run even though it is seen taking up more than 2G in
 footprint. My problem is capacity planning on the server whereby since my
 python process doesn't release memory back to the OS, the OS wasn't able to
 allocate memory when a new process is spawn off.

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

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


Re: Apparent magic number problem

2013-03-09 Thread Colin J. Williams

On 09/03/2013 3:51 AM, Peter Otten wrote:

Colin J. Williams wrote:

The program runs correctly under each version, but it runs more slowly
under 3.2.



This is probably due to the fact that the .pyc file is created for the
Python 2.7 execution.



When Python 3.2 is run it fails to create a new .pyc file and if the 2.7
.pyc is offered directly a magic number problem is reported.


(1) .pyc files are only created if a module is imported
(2) The 2.7 .pyc file is put alongside the .py file whereas the 3.2 .pyc is
put into the __pycache__ subfolder. No clash can occur.

A simple example:

$ ls
mod.py
$ cat mod.py
print(hello world)

Run it; no pyc is created:

$ python2.7 mod.py
hello world
$ ls
mod.py

Import it using 2.7:

$ python2.7 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc

Import it using 3.2:

$ python3.2 -c 'import mod'
hello world
$ ls
mod.py  mod.pyc  __pycache__
$ ls __pycache__/
mod.cpython-32.pyc

Run the compiled code:

$ python2.7 mod.pyc
hello world
$ python3.2 __pycache__/mod.cpython-32.pyc
hello world

But I'm with Steven, it's unlikely that the module compilation phase is
responsible for a noticeable slowdown.



Thanks to Steven and Peter for their responses.

My main problem appears to be with:

Profile with Python 2.7
   11   25.7362.340   25.7362.340 
{numpy.linalg.lapack_lite.dgesv}


Profile with Python 3.2
   11  152.111   13.828  152.111   13.828 {built-in method dgesv}

In other words, the Python 3.2 linear equation solve takes longer than 
with Python 2.7.   I'll pursue this with the numpy folk.


There also appears to be a problem with the generation of the .pyc. 
Please see the example below:


rem temp.bat
dir *.pyc
del *.pyc
C:\python32\python.exe profiler.py Intel P4 2.8GHz 2MB Ram 221 GB Free 
Disk cjw prof3.txt

dir *.pyc

This is executed with: tmp.bat  tmp.lst

profiler.py contains:
#---
# Name:profiler.py
# Purpose:
#
# Author:  cjw
#
# Created: 17/02/2013
# Copyright:   (c) cjw 2013
# Licence: your licence
#---

import  cProfile as p, pstats as s, sys

def main():
v= sys.version
statsFile= 'FPSStats' + v[0] + v[2] + '.txt'
p.run('import testFPSpeed; testFPSpeed.main()',
 statsFile)
t= s.Stats(statsFile)
t.strip_dirs().sort_stats('cumulative').print_stats(40)

pass

if __name__ == '__main__':
main()

tmp.lst contains:

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi




tmp.lst contains:

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspirem temp.bat

C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidel *.pyc

C:\Documents and Settings\cjw.P4A\My 
Documents\devpy\raspiC:\python32\python.exe profiler.py Intel P4 2.8GHz 
2MB Ram 221 GB Free Disk cjw 1prof3.txt


C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspidir *.pyc
 Volume in drive C has no label.
 Volume Serial Number is D001-FAC4

 Directory of C:\Documents and Settings\cjw.P4A\My Documents\devpy\raspi

From this we see that no .pys was reported for testFPSpeed.py.

However, looking at the directory itself. the .pyc is in fact created.

Thus,  the .pyc is, if necessary, generated upon the import of a .py and 
so this does not explain the time difference between 2.7 and 3.2.



Re: An error when i switched from python v2.6.6 = v3.2.3

2013-03-09 Thread rusi
On Mar 9, 7:16 pm, Νίκος Γκρ33κ nikos.gr...@gmail.com wrote:
 Is there a way to see anserws to my posts via ThunderBird that doesn't hve 
 this formatting issue?

I had posted a suggestion to get back to 'old google groups' here.
Usually if you (can) switch to the old these problems vanish

http://mail.python.org/pipermail/python-list/2012-October/633460.html

[According to Alex it seems you may have to actively select the new
before you can select the old]
-- 
http://mail.python.org/mailman/listinfo/python-list


http://stackoverflow.com/questions/15311450/my-chat-client-freezes-up-after-beginning-threads

2013-03-09 Thread Owatch
I made a better chat client following help from people:

They told me that if I didn't want to be blocked on .recv when waiting for 
messages,  I would need to use threads, classes, functions, and queues 
to do so. 

So I followed some help a specific person gave me where I created a thread from 
a class and then defined a function that was supposed to read incoming messages 
and print them. 

I also created a function that allows you to enter stuff to be sent off. 

Thing is, when I run the program. Nothing happens. 

Can somebody help point out what is wrong? (I've asked questions and researched 
for 3 days, without getting anywhere, so I did try)



from socket import *
import threading
import json
import select

print(Client Version 3)
HOST = input(Connect to: )
PORT = int(input(On port: ))
# Create Socket

s = socket(AF_INET,SOCK_STREAM)
s.connect((HOST,PORT))
print(Connected to: ,HOST,)

#---Need 2 threads for handling incoming and outgoing 
messages--

#   1: Create out_buffer:
Buffer = []

rlist,wlist,xlist = select.select([s],Buffer,[])

class Incoming(threading.Thread):
# made a function a thread
def Incoming_messages():
while True:
for i in rlist:
data = i.recv(1024)
if data:
print(data.decode())

# Now for outgoing data.
def Outgoing():
while True:
user_input=(Your message: )
if user_input is True:
Buffer += [user_input.encode()]
for i in wlist:
s.sendall(Buffer)
Buffer = []


Thanks for taking a look, thanks also to Tony The Lion for suggesting this

If the code isnt done right, here's a link to view it, and download:

View: http://i1267.photobucket.com/albums/jj554/owatch/PPP_zps4beb891b.png
Download: http://www.mediafire.com/?u51a9b5axfffoxl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
OK. Sorry to have caused all the confusion. Let me try this again.

To use my program the user needs a script file I will call user.py. 
Functions from my program must be imported into this file with 
something like from myapp import *.

myapp.py is a module in my program that has all the functions that the 
user needs to describe building components. There is also a main 
controller object that is imported into myapp.py module called app.

When python parses user.py module, the functions the user has provided 
creates building components which are then saved in a dictionary 
located in an object called doc that is part of my program. 

The user is free to use the functions in myapp.py to describe building 
components. When this process is complete or when the user wants to 
view their work-in-progress, they have to place a function called 
view() on the last line in user.py. This function currently exports 
the components into POV-Ray or OpenSCAD format. These are CAD programs 
that read script files to render or create images of the described 
artifacts. So this means that to view their work the user needs to run 
python on user.py to export the building and then run POV-Ray or 
OpenSCAD on the exported file to see the building.

I want to make it possible for the user to preview the building 
components without having to use the external rendering programs. I 
can currently have the app object provide this preview but it means 
that the user will have to process user.py with python then exit the 
graphic window each time they need to see changes.

So the solution I am looking for is to have a graphic window open that 
watches user.py for changes. If there is a change the graphic window 
updates the rendition of the created components without further 
intervention by the user. However this means that the graphic must 
somehow run python to parse user.py and then be able to access the 
objects stored in doc so that the coordinates can be used to update 
the view. This is where I am having difficulty.

I hope this is clearer.
-- 

Kene
::
kemen...@gmail.com

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


read and write the same text file

2013-03-09 Thread iMath
read and write the same text file 
Open a text file ,read the content ,then make some change on it ,then write it 
back to the file ,now the modified text  should only has the modified content 
but not the initial content ,so can we implement this by only set the mode 
parameter with open() function ?if yes ,what the parameter should be ?if no 
,can we implement this by only one with statement ?
I implement this with 2 with statement as the following 

replace_pattern = re.compile(r.+?,re.DOTALL)

def text_process(file):

with open(file,'r') as f:
text = f.read()

with open(file,'w') as f:
f.write(replace_pattern.sub('',text))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: read and write the same text file

2013-03-09 Thread Roy Smith
In article c41028f7-e457-4a2b-99f4-c473eaadd...@googlegroups.com,
 iMath redstone-c...@163.com wrote:

 read and write the same text file 
 Open a text file ,read the content ,then make some change on it ,then write 
 it back to the file ,now the modified text  should only has the modified 
 content but not the initial content ,so can we implement this by only set the 
 mode parameter with open() function ?if yes ,what the parameter should be ?if 
 no ,can we implement this by only one with statement ?
 I implement this with 2 with statement as the following 
 
 replace_pattern = re.compile(r.+?,re.DOTALL)
 
 def text_process(file):
 
 with open(file,'r') as f:
 text = f.read()
 
 with open(file,'w') as f:
 f.write(replace_pattern.sub('',text))

At a minimum, you need to close the file after you read it and before 
you re-open it for writing.

There's a variety of ways you could achieve the same effect.  You might 
open the file once, in read-write mode, read the contents, rewind to the 
beginning with seek(), then write the new contents.  You might also 
write the modified data out to a new file, close it, and then rename it.  
But, open, read, close, open, write, close is the most straight-forward.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running external module and accessing the created objects

2013-03-09 Thread Dave Angel

On 03/09/2013 10:34 AM, Kene Meniru wrote:

OK. Sorry to have caused all the confusion. Let me try this again.



Thank you very much.  This is much clearer, though it's not all here.


To use my program the user needs a script file I will call user.py.
Functions from my program must be imported into this file with
something like from myapp import *.


And does the user run this script by doing
python  user.py



myapp.py is a module in my program that has all the functions that the
user needs to describe building components. There is also a main
controller object that is imported into myapp.py module called app.

When python parses user.py module,


You presumably mean, When Python runs the script user.py


the functions the user has provided
creates building components which are then saved in a dictionary
located in an object called doc that is part of my program.


What program is that?  Looks to me like you're writing a series of 
modules, a framework perhaps, that is invoked by the user script.




The user is free to use the functions in myapp.py to describe building
components. When this process is complete or when the user wants to
view their work-in-progress, they have to place a function called
view() on the last line in user.py.


Don't you mean the code in user.py has to *call* the function app.view() 
when they're all done with defining the components?  That has nothing to 
do with being the last line.



This function currently exports


You mean writes files into the file system?


the components into POV-Ray or OpenSCAD format. These are CAD programs
that read script files to render or create images of the described
artifacts. So this means that to view their work the user needs to run
python on user.py to export the building and then run POV-Ray or
OpenSCAD on the exported file to see the building.


At that point, the user.py script has completed, and Python is done, right?



I want to make it possible for the user to preview the building
components without having to use the external rendering programs. I
can currently have the app object provide this preview but it means
that the user will have to process user.py with python then exit the
graphic window each time they need to see changes.


What changes are those?  You can't change a script while it's executing. 
 Could you clarify this so I can rethink the following paragraph?




So the solution I am looking for is to have a graphic window open that
watches user.py for changes. If there is a change the graphic window
updates the rendition of the created components without further
intervention by the user. However this means that the graphic must
somehow run python to parse user.py and then be able to access the
objects stored in doc so that the coordinates can be used to update
the view. This is where I am having difficulty.

I hope this is clearer.





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


RFD: comp.sys.raspberry-pi

2013-03-09 Thread James Harris

  REQUEST FOR DISCUSSION (RFD)
unmoderated group comp.sys.raspberry-pi

This is a formal Request for Discussion (RFD) for the creation of the
unmoderated newsgroup comp.sys.raspberry-pi.

NEWSGROUPS LINE:
comp.sys.raspberry-pi   Raspberry Pi computers  related hardware and
software.

RATIONALE:

* Discussions on this topic have so far been widely and thinly spread
on Usenet
  - e.g. google site:groups.google.com/group/comp raspberry pi
* Device has been on sale for over a year (since 29 Feb 2012)
* Circa 1 million units sold so far
  - http://www.wired.com/design/2013/01/raspberry-pi-million-boards/
* The maker's web forum, while it is a web site and not Usenet,
currently reports over 299,000 posts and 33,000 threads giving an
indication of the levels of interest in discussion
  - http://www.raspberrypi.org/phpBB3/
* The Raspberry Pi is complex and used by communities having technical
issues to discuss
* Various third-party add-ons are available
* The device has some distinctive features, e.g.,
  * Low cost - base retail prices US$25/35 depending on model
  * Header for interfacing with external electronics
  * Can generate 1080p30 High Definition video
* For further specs see http://en.wikipedia.org/wiki/Raspberry_Pi
* People have been using the device for a variety of unusual purposes
  - http://www.raspberrypi.org/phpBB3/viewforum.php?f=15

All-in-all there seems to be many reasons why a Usenet group would be
well used but to allow the Big 8 Management Board to make an informed
decision if you would read and/or post to the proposed newsgroup
please indicate your interest by replying on this thread. Followups
are set to news.groups.proposals where discussions about the proposal
can be carried out.


CHARTER:

Newsgroup comp.sys.raspberry-pi is for discussion of issues connected
with Raspberry Pi computer systems including set up, programming,
software, operating systems, interfacing, related hardware and
projects.

Posters are expected to abide by normal Usenet standards of decorum,
and to ignore articles intended to disrupt the group.  The usual
suspects are prohibited (spam, binaries, direct advertising, etc.)


PROCEDURE:

For more information on the newsgroup creation process, please see:

  http://www.big-8.org/dokuwiki/doku.php?id=policies:creation

Those who wish to influence the development of this RFD and its final
resolution should subscribe to news.groups.proposals and participate
in the relevant threads in that newsgroup.  This is both a courtesy to
groups in which discussion of creating a new group is off-topic as
well as the best method of making sure that one's comments or
criticisms are heard.

All discussion of active proposals should be posted to
news.groups.proposals

To this end, the followup header of this RFD has been set to
news.groups.proposals.

If desired by the readership of closely affected groups, the
discussion may be crossposted to those groups, but care must be taken
to ensure that all discussion appears in news.groups.proposals as
well.

We urge those who would like to read or post in the proposed newsgroup
to make a comment to that effect in this thread; we ask proponents to
keep a list of such positive posts with the relevant message ID:

Barney Fife, 4jgdnb60fsmzha7znz2dnuvz_rwdn...@sysmatrix.net)

Such lists of positive feedback for the proposal may constitute good
evidence that the group will be well-used if it is created.

DISTRIBUTION:

This document has been posted to the following newsgroups:

  news.announce.newgroups
  news.groups.proposals
  comp.lang.forth
  comp.lang.python
  comp.os.linux.misc


PROPONENT:

James Harris james.harris.1Agmail.com (replace A with @ - but please
discuss the proposal on Usenet!)

CHANGE HISTORY:
2013-03-09  Initial RFD

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


Re: http://stackoverflow.com/questions/15311450/my-chat-client-freezes-up-after-beginning-threads

2013-03-09 Thread Andrew Berg
On 2013.03.09 09:26, Owatch wrote:
 Thing is, when I run the program. Nothing happens. 
 
 Can somebody help point out what is wrong? (I've asked questions and 
 researched for 3 days, without getting anywhere, so I did try)
You defined a thread, but never created or started it. Also, why did you
subclass threading.Thread? You also mentioned queues, but you didn't use
them.

Not tested, but shows the basics:

import threading
import queue
import socket

def process():
  while alive:
thing = things_to_process.get()
# do stuff with the thing here
things_to_process.task_done()

alive = True
host = 'localhost'
port = 
things_to_process = queue.Queue()
process_thread = threading.Thread(target=process)
process_thread.start()
sock = socket.socket()
sock.connect((host, port))
while alive:
  try:
data = sock.recv()
  except Exception: # should probably do different things for different
errors in real code
alive = False
sock.close()
process_thread.join()
raise
  else:
things_to_process.put(data)

-- 
CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running external module and accessing the created objects

2013-03-09 Thread Rick Johnson
On Saturday, March 9, 2013 9:34:53 AM UTC-6, Kene Meniru wrote:
 OK. Sorry to have caused all the confusion. Let me try
 this again.

Sounds to me like you should solve this problem in two manners:


 Interactive Input
 

Create an interactive environment where the user can enter commands directly 
into the namespace using your API in real time, then when he is ready to see 
the result of those commands, he can call display command or push a display 
button and the App will run the appropriate outside programs to show the 
visualization. 


 Scripts loaded at runtime
 

If you prefer the user to write scripts, and then have your App read these 
scripts (and create visualizations from the commands within the scripts) then 
the only difference between step 1 and step 2 is *when* the commands are 
interpreted. In this case your app will *load* the scripts AFTER they are 
completely written (this could be done automatically by the app at runtime IF 
the path to these scripts is known, or could be accomplished by the user 
picking files in a dialog (Menu-RunScript).

I think you are trying to create step 1 without the interactive environment. 
This is your mistake. Having users work with raw files and then *somehow* 
watching a raw file for certain display commands (in real time) is folly. 

Heck, when you edit a file in a text editor you are only seeing a 
representation of the file from the last time it was saved, and your app could 
never know when the file data and the file view where synchronized; without 
an asinine amount of foolish programming of course.

If this is not what you want, then i suggest you create a simple representation 
of your code (or link to the actual code).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Dave Angel wrote:

 On 03/09/2013 10:34 AM, Kene Meniru wrote:

 To use my program the user needs a script file I will call user.py.
 Functions from my program must be imported into this file with
 something like from myapp import *.
 
 And does the user run this script by doing
  python  user.py
 

Yes


 myapp.py is a module in my program that has all the functions that the
 user needs to describe building components. There is also a main
 controller object that is imported into myapp.py module called app.

 When python parses user.py module,
 
 You presumably mean, When Python runs the script user.py
 

When the user types and enters at the command line: python user.py

 the functions the user has provided
 creates building components which are then saved in a dictionary
 located in an object called doc that is part of my program.
 
 What program is that?  Looks to me like you're writing a series of
 modules, a framework perhaps, that is invoked by the user script.


Yes. I am writing many functions and classes in many modules that work 
together.
 

 The user is free to use the functions in myapp.py to describe building
 components. When this process is complete or when the user wants to
 view their work-in-progress, they have to place a function called
 view() on the last line in user.py.
 
 Don't you mean the code in user.py has to *call* the function app.view()
 when they're all done with defining the components?  That has nothing to
 do with being the last line.

Well... yes. The function is app.view() but it is not called automatically 
by the code in user.py. The following is an example of the contents of 
user.py

### begin user.py #
from buildes import *

site(Willow_Creek_Ct, 5)
Create a site with name and number of boundaries.
level(level1, 3000)
level(level2, 3000)
Create levels with name and height.
setLevel(level1)
Set the current level to place objects
space(Dining, 5)
Create a space with 5 sides (walls)
linearSide(Dining-S1, 3683, 152, 0)
Initialize the first side of space called Dining
offset(Dining-S1, (3000, 0, 0))
Install the first side of Dining space called Dining-S1
view(POV)
Exports objects to POV-Ray format
### end user.py #

 
 This function currently exports
 
 You mean writes files into the file system?
 

Yes.

 the components into POV-Ray or OpenSCAD format. These are CAD programs
 that read script files to render or create images of the described
 artifacts. So this means that to view their work the user needs to run
 python on user.py to export the building and then run POV-Ray or
 OpenSCAD on the exported file to see the building.
 
 At that point, the user.py script has completed, and Python is done,
 right?
 

Yes


 I want to make it possible for the user to preview the building
 components without having to use the external rendering programs. I
 can currently have the app object provide this preview but it means
 that the user will have to process user.py with python then exit the
 graphic window each time they need to see changes.
 
 What changes are those?  You can't change a script while it's executing.
   Could you clarify this so I can rethink the following paragraph?
 

Working on the user.py is an iterative process. The user adds new objects or 
changes the parameters of the objects already there and envokes python 
user.py each time to see the changes made. Just like using a program like 
LaTeX. You edit your text file and run LaTeX on the file to see the changes 
you made. The process continues until you finish the document. 



 So the solution I am looking for is to have a graphic window open that
 watches user.py for changes. If there is a change the graphic window
 updates the rendition of the created components without further
 intervention by the user. However this means that the graphic must
 somehow run python to parse user.py and then be able to access the
 objects stored in doc so that the coordinates can be used to update
 the view. This is where I am having difficulty.

-- 

Kene
::
kemen...@gmail.com

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Dave Angel

On 03/09/2013 11:56 AM, Kene Meniru wrote:

Dave Angel wrote:


On 03/09/2013 10:34 AM, Kene Meniru wrote:



To use my program the user needs a script file I will call user.py.
Functions from my program must be imported into this file with
something like from myapp import *.


And does the user run this script by doing
  python  user.py



Yes



myapp.py is a module in my program that has all the functions that the
user needs to describe building components. There is also a main
controller object that is imported into myapp.py module called app.

When python parses user.py module,


You presumably mean, When Python runs the script user.py



When the user types and enters at the command line: python user.py


the functions the user has provided
creates building components which are then saved in a dictionary
located in an object called doc that is part of my program.


What program is that?  Looks to me like you're writing a series of
modules, a framework perhaps, that is invoked by the user script.



Yes. I am writing many functions and classes in many modules that work
together.



The user is free to use the functions in myapp.py to describe building
components. When this process is complete or when the user wants to
view their work-in-progress, they have to place a function called
view() on the last line in user.py.


Don't you mean the code in user.py has to *call* the function app.view()
when they're all done with defining the components?  That has nothing to
do with being the last line.


Well... yes. The function is app.view() but it is not called automatically
by the code in user.py. The following is an example of the contents of
user.py

### begin user.py #
from buildes import *

site(Willow_Creek_Ct, 5)
Create a site with name and number of boundaries.
level(level1, 3000)
level(level2, 3000)
Create levels with name and height.
setLevel(level1)
Set the current level to place objects
space(Dining, 5)
Create a space with 5 sides (walls)
linearSide(Dining-S1, 3683, 152, 0)
Initialize the first side of space called Dining
offset(Dining-S1, (3000, 0, 0))
Install the first side of Dining space called Dining-S1
view(POV)
Exports objects to POV-Ray format
### end user.py #




This function currently exports


You mean writes files into the file system?



Yes.


the components into POV-Ray or OpenSCAD format. These are CAD programs
that read script files to render or create images of the described
artifacts. So this means that to view their work the user needs to run
python on user.py to export the building and then run POV-Ray or
OpenSCAD on the exported file to see the building.


At that point, the user.py script has completed, and Python is done,
right?



Yes



I want to make it possible for the user to preview the building
components without having to use the external rendering programs. I
can currently have the app object provide this preview but it means
that the user will have to process user.py with python then exit the
graphic window each time they need to see changes.


What changes are those?  You can't change a script while it's executing.
   Could you clarify this so I can rethink the following paragraph?



Working on the user.py is an iterative process. The user adds new objects or
changes the parameters of the objects already there and envokes python
user.py each time to see the changes made. Just like using a program like
LaTeX. You edit your text file and run LaTeX on the file to see the changes
you made. The process continues until you finish the document.




So the solution I am looking for is to have a graphic window open that
watches user.py for changes.


It would then have to be a separate executable.  Are you really saying 
you want this window to keep running after the script ends?  And that 
somehow it notices that the user has rerun the  user.py script?  Or 
could it simply be a window created during the user.py run that stays 
running till it's closed, which ends the script as well?



If there is a change the graphic window
updates the rendition of the created components without further
intervention by the user.


Is running the script considered intervention?  Or do you mean literally 
that somebody watches the script for changes (eg. by watching the 
timestamp)?



However this means that the graphic must
somehow run python to parse user.py and then be able to access the
objects stored in doc so that the coordinates can be used to update
the view. This is where I am having difficulty.




Either the graphic is in the same process, in which case the script 
can only be parsed once, or the graphic is in a second process, in 
which case you're talking some interesting interprocess communication 
(ipc).  That's certainly do-able, but it's way beyond the scope of the 
kind of programming you've been talking about.  But sometimes just using 
a regular file for transfer is 

Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Rick Johnson wrote:

 On Saturday, March 9, 2013 9:34:53 AM UTC-6, Kene Meniru wrote:

 
  Interactive Input
 
 
 Create an interactive environment where the user can enter commands
 directly into the namespace using your API in real time, then when he is
 ready to see the result of those commands, he can call display command
 or push a display button and the App will run the appropriate outside
 programs to show the visualization.
 
 
  Scripts loaded at runtime
 
 
 If you prefer the user to write scripts, and then have your App read
 these scripts (and create visualizations from the commands within the
 scripts) then the only difference between step 1 and step 2 is *when* the
 commands are interpreted. In this case your app will *load* the scripts
 AFTER they are completely written (this could be done automatically by the
 app at runtime IF the path to these scripts is known, or could be
 accomplished by the user picking files in a dialog (Menu-RunScript).
 

Please see my last response to Dave Angel. I think it is possible for a 
program to watch a file. I am not interested in menus which is why I am 
going this route. I could easily use PyQt to make this but I am not 
interested in graphical user interfaces. Are you are familiar with LaTeX? 
That is the system I very much want to emulate.

 I think you are trying to create step 1 without the interactive
 environment. This is your mistake. Having users work with raw files and
 then *somehow* watching a raw file for certain display commands (in
 real time) is folly.
 

It is possible to watch files for changes without user intervention. If a 
change is detected (whether by file size or time) the file can be executed 
as all python modules can be using python FILENAME.py. How is this folly?

 Heck, when you edit a file in a text editor you are only seeing a
 representation of the file from the last time it was saved, and your app
 could never know when the file data and the file view where
 synchronized; without an asinine amount of foolish programming of course.
 
 If this is not what you want, then i suggest you create a simple
 representation of your code (or link to the actual code).

My code is available at http://sourceforge.net/projects/buildes. The 
documentation is at http://buildes.sourceforge.net/. 

-- 

Kene
::
kemen...@gmail.com

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Dave Angel wrote:


 So the solution I am looking for is to have a graphic window open that
 watches user.py for changes.
 
 It would then have to be a separate executable.  

This is my thinking too.

 Are you really saying
 you want this window to keep running after the script ends?  And that
 somehow it notices that the user has rerun the  user.py script?  Or
 could it simply be a window created during the user.py run that stays
 running till it's closed, which ends the script as well?

Following the idea that it should be a separate executable, the user does 
not have to run the script by doing python user.py as they would normally 
do. The window takes this over. It sits there watching for changes to 
user.py such as change in file size and/or time or if the user hits the 
enter key while it has focus.

My question really is how can the graphics window have access to the objects 
saved in the dictionary of the doc object after running python user.py. It 
need to do this to be able to use their coordinates to redraw the view.

 
 If there is a change the graphic window
 updates the rendition of the created components without further
 intervention by the user.
 
 Is running the script considered intervention?  Or do you mean literally
 that somebody watches the script for changes (eg. by watching the
 timestamp)?
 

I do not understand. What I mean is that this happens automatically. The 
user no longer needs to do python user.py the graphics window now should 
do this for the user when changes are detected in user.py by watching 
timestamp for example. 

 However this means that the graphic must
 somehow run python to parse user.py and then be able to access the
 objects stored in doc so that the coordinates can be used to update
 the view. This is where I am having difficulty.


 If you really want two processes, then you should consider having the
 user run the the graphic app, with a commandline parameter of user.py,
 and have it create the user.py process.  The user.py process runs till
 it has created all the data, then sends it via some ipc to the graphic
 app.  Once sent, it terminates.  The graphic app reads the ipc stuff,
 updates its graphics, then idles, watching for timestamp changes on the
 user.py file.
 

This sounds interesting. What is ipc. Can you give me an example?

 

-- 

Kene
::
kemen...@gmail.com

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Kene Meniru
Kene Meniru wrote:

 Dave Angel wrote:

 If you really want two processes, then you should consider having the
 user run the the graphic app, with a commandline parameter of user.py,
 and have it create the user.py process.  The user.py process runs till
 it has created all the data, then sends it via some ipc to the graphic
 app.  Once sent, it terminates.  The graphic app reads the ipc stuff,
 updates its graphics, then idles, watching for timestamp changes on the
 user.py file.
 
 
 This sounds interesting. What is ipc. Can you give me an example?


Actually there is a possible simple solution consistent with the way my 
program works already. 

I can just provide another exporter for OpenGL that pyglet.window.Window()  
subclass will be able to read. So I will provide another parameter for OGL 
so the user can use view(OGL). When the user.py script is run, all objects 
in doc are converted and exported to a file that the graphics window is 
watching. The contents will then be used to update the view. So this means 
that the user or the graphics window object can run python user.py it no 
longer matters how.

Thanks for your comments. 

-- 

Kene
::
kemen...@gmail.com

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


Re: Running external module and accessing the created objects

2013-03-09 Thread Rick Johnson
On Saturday, March 9, 2013 11:21:20 AM UTC-6, Kene Meniru wrote:

 Please see my last response to Dave Angel. I think it is
 possible for a program to watch a file. I am not
 interested in menus which is why I am going this route. I
 could easily use PyQt to make this but I am not interested
 in graphical user interfaces. 

Yes, using a non-GUI interface is always much simpler to code than a GUI. I can 
see the merit in that approach.

 It is possible to watch files for changes without user
 intervention. If a change is detected (whether by file
 size or time)

Indeed, but the file data on disc and the file data in the text editor cannot 
be guaranteed to be exact representations of each other at any random sample of 
time.
 
 the file can be executed as all python
 modules can be using python FILENAME.py. 

I understand that Python files can be executed (as we all do). 

 How is this folly?

Well i don't have enough information *yet* to decide if your program design is 
folly, but i can assure you that your explanations of how this program will 
function are. My problem with your workflow is that it ignores the need to 
constantly save the edited file data back to disc, because i assume you are 
using a text editor to edit the .py files. Sure, you could create a behavior 
of the editor to save the changes after every keystroke, or every newline, or 
whatever; but you failed to mentioned how any of this will work.

 My code is available at
 http://sourceforge.net/projects/buildes. The documentation
 is at http://buildes.sourceforge.net/.

Well GEE-GOLLY-GARSH, thanks for finally posting something we can draw 
coherency from. May i suggest that next time you post the links in the very 
first post? I mean, i like playing guess the number as much as the next guy, 
but geez!

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


Re: Calling J from Python

2013-03-09 Thread gosinn
Den måndagen den 5:e februari 2007 kl. 14:48:49 UTC skrev Gosi:
 It is quite easy to call J from Python
 
 http://groups.google.com/group/J-Programming/browse_thread/thread/5e84b75667f5f64e

http://www.jsoftware.com/jwiki/Scripts/qjide
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are timezone aware and naive datetimes not distinct classes?

2013-03-09 Thread Nobody
On Sat, 09 Mar 2013 09:01:17 +1100, Chris Angelico wrote:

 As I see it, a naive datetime simply does not have a timezone.

The distinction between aware and naive isn't whether the .tzinfo member
is None, but whether self.utcoffset() returns None (which can occur either
if self.tzinfo is None or if self.tzinfo.utcoffset(self) returns None).

IOW, an aware time/datetime can be converted to a UTC time/datetime, a
naive one can't, although it can still have a timezone which isn't
referenced to UTC.

The distinction may actually matter for times in the far future, as you
can't reliably predict how or when timezone defintions will change.
Converting a future datetime to UTC based upon the current timezone rules
is at best an estimate. For this reason, appointments should always be
kept in local time, so that you don't get errors if the timezone rules
(or the timezone) change between the time an appointment is made and the
time it occurs.

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


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Grant Edwards
On 2013-03-09, Wong Wah Meng-R32813 r32...@freescale.com wrote:

Your entire post is in your signature block. Don't do that. Many
people have newsreaders or e-mail clinets configured to hide or ignore
signature blocks.

Yes I have verified my python application is reusing the memory (just
that it doesn't reduce once it has grown) and my python process
doesn't have any issue to run even though it is seen taking up more
than 2G in footprint.

Then there's nothing wrong with Python.

My problem is capacity planning on the server whereby since my python
process doesn't release memory back to the OS,

In Unix there is no way to release heap memory (which is what you're
talking about) back to the OS except for terminating the process.

the OS wasn't able to allocate memory when a new process is spawn off.

You need to either get more memory, change your Python program to use
less memory, or have your Python program terminate in order to return
memory to the OS.

Perhaps you can put the memory hungery portion of your processing into
a subprocess that terminates when it's completed its work?

-- 
Grant Edwards   grant.b.edwardsYow! Don't hit me!!  I'm in
  at   the Twilight Zone!!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling J from Python

2013-03-09 Thread Mark Lawrence

On 09/03/2013 18:49, gos...@gmail.com wrote:

Den måndagen den 5:e februari 2007 kl. 14:48:49 UTC skrev Gosi:

It is quite easy to call J from Python

http://groups.google.com/group/J-Programming/browse_thread/thread/5e84b75667f5f64e


http://www.jsoftware.com/jwiki/Scripts/qjide



Got a right slagging six years ago when first posted, what's changed to 
make it worth evaluating?


--
Cheers.

Mark Lawrence

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


Re: Why are timezone aware and naive datetimes not distinct classes?

2013-03-09 Thread Roy Smith
In article pan.2013.03.09.19.14.59.699...@nowhere.com,
 Nobody nob...@nowhere.com wrote:

 The distinction may actually matter for times in the far future, as you
 can't reliably predict how or when timezone defintions will change.

Sadly, this is true.

 For this reason, appointments should always be
 kept in local time, so that you don't get errors if the timezone rules
 (or the timezone) change between the time an appointment is made and the
 time it occurs.

Well, sort of.  Future scheduled activities (which I assume is what you 
mean by appointments) should be kept in whatever timezone makes sense 
for that activity.  For example, I'm on NASA's mailing list to receive 
alerts when the ISS is going to be visible to the naked eye at my 
location.  The last one said:

 Time: Wed Feb 27 6:17 PM, Visible: 4 min, Max Height: 54 degrees, 
 Appears: W, Disappears: SE

If I wanted to put that on my calendar, I really should convert it to 
UTC and record it that way.  If the folks who mess with these things 
were to suddenly decide to move when DST starts, the space station isn't 
going to adjust its orbit to accommodate that.

Likewise, let's say I make an appointment to have a phone call with 
somebody in Caliornia (I'm in New York) at some future date.  I put on 
my calendar Call with Joe, 5 PM.  Joe puts on his, Call with Roy, 2 
PM.  The idiots in Albany and/or Sacramento decide to mess with the 
timezones and one state changes the rules.  We're going to miss our 
phone call.  Had we both recorded the arranged time in UTC, we'd get to 
talk to each other.
-- 
http://mail.python.org/mailman/listinfo/python-list


how to déplace a circle in canvas python?

2013-03-09 Thread olsr . kamal
how to diplace a circle in canvas tkinter python from position to an auther 
position by a mouse click 'press' 'relase' or by delete the déplicated objects 
in canvas??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Roy Smith
In article khg1v3$l7q$1...@reader2.panix.com,
 Grant Edwards invalid@invalid.invalid wrote:

 In Unix there is no way to release heap memory (which is what you're
 talking about) back to the OS except for terminating the process.

That's not quite true.  The man page for BRK(2) (at least on the Linux 
box I happen to have handy) says:

brk() and sbrk() change the location of the program break, which 
defines the  end  of  the process's data segment (i.e., the program 
break is the first location after the end of the uninitialized data 
segment).  Increasing the program break has the  effect  of  allocating 
memory to the process; decreasing the break deallocates memory.

So, in theory, it's possible.  I just ran this C program:

#include unistd.h
#include time.h

int main(int argc, char** argv) {
struct timespec t;
t.tv_sec = 10;
t.tv_nsec = 0;

nanosleep(t, NULL);
sbrk(500 * 1024 * 1024);

nanosleep(t, NULL);
sbrk(-500 * 1024 * 1024);

nanosleep(t, NULL);
}

while watching the process with ps.  I could see the process appear and 
for the first 10 seconds it had a VSZ of 4156.  Then, for the next 10 
seconds, the VSZ was 516156, then it went back down to 4156.

$ while sleep 1; do ps augx | grep a.out | grep -v grep; done
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0 516156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out
roy   6657  0.0  0.0   4156   356 pts/10   S+   19:56   0:00 ./a.out

In practice, unless you go to extraordinary lengths (i.e. avoid almost 
all of the standard C library), the break is going to be managed by 
malloc(), and malloc() provides no way to give memory back (insert 
handwave here about mmap, and another handwave about various versions of 
malloc).  But, that's due to the way malloc() manages its arena, not 
anything fundamental about how Unix works.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: itertools.filterfalse - what is it good for

2013-03-09 Thread Miki Tebeka

 can anybody point out a situation where you really need 
 itertools.filterfalse() ?
Sometimes you get the predicate as a parameter to another function. This way if 
you want to filter out things you can easily do it. Other language (such as 
Clojure) have a complement function that removes the need of filterfalse.

For example (Python 3):
def percent_spam(is_spam, documents):
n_spam = sum(1 for _ in filter(is_spam, documents))
n_ham = sum(1 for _ in filterfalse(is_spam, documents))
return float(n_spam) / (n_ham + n_spam)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Grant Edwards
On 2013-03-09, Roy Smith r...@panix.com wrote:
 In article khg1v3$l7q$1...@reader2.panix.com,
  Grant Edwards invalid@invalid.invalid wrote:

 In Unix there is no way to release heap memory (which is what you're
 talking about) back to the OS except for terminating the process.

 That's not quite true.  The man page for BRK(2) (at least on the Linux 
 box I happen to have handy) says:

 brk() and sbrk() change the location of the program break, which 
 defines the  end  of  the process's data segment (i.e., the program 
 break is the first location after the end of the uninitialized data 
 segment).  Increasing the program break has the  effect  of  allocating 
 memory to the process; decreasing the break deallocates memory.

 So, in theory, it's possible.

Well spotted.  I would have bet money (OK, not a lot), that sbrk()
only accepted positive increment values.  I seem to have conflated
what sbrk() will accept and the fact that the C library's malloc/free
calls never call sbrk() with a nagative number.

[... nicely done demonstraction of negative sbrk() parameter usage ...]

 In practice, unless you go to extraordinary lengths (i.e. avoid
 almost all of the standard C library), the break is going to be
 managed by malloc(), and malloc() provides no way to give memory back
 (insert handwave here about mmap, and another handwave about various
 versions of malloc).  But, that's due to the way malloc() manages its
 arena, not anything fundamental about how Unix works.

Indeed.

What I should have said was that there's no way to return to the OS
memory obtained via calls to malloc() et al, and those are the calls
that good C programmers (like the maintainers of CPython) use.

In theory, you could modify the C library so that calls to free()
might return memory to the OS.  Sometimes.  If you're lucky.

The problem is that if there's _one_byte_ of memory in use at the
end of the heap region, it doesn't matter if there's an unused 16GB
chunk in the middle -- it can't be returned to the OS.

-- 
Grant Edwards   grant.b.edwardsYow! Look DEEP into the
  at   OPENINGS!!  Do you see any
  gmail.comELVES or EDSELS ... or a
   HIGHBALL?? ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to déplace a circle in canvas python?

2013-03-09 Thread Rick Johnson
On Saturday, March 9, 2013 1:47:43 PM UTC-6, olsr@gmail.com wrote:
 how to [translate] a circle in canvas tkinter python from
 [one] position to an [another] position 

Well translation is by definition: changing an objects position

 by a mouse click 'press' ['release'] or by delete the [duplicated] objects
 in canvas??

Here's an idea: how about you learn how to translate a Tkinter canvas object 
via code BEFORE you try to do it via user input? This is called code evolution 
along an intelligent linear path, not some random shots in the dark.

How do you do this you ask, well i'll give you a hint, follow this yellow brick 
road for enlightenment.


 STEP 1


Take a look at the following methods available to the Tkinter canvas widget 
here:

 http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/canvas-methods.html
 
Can you find a method that will translate or displace or (insert another 
synonym here), a canvas object by passing two (x,y) Cartesian coordinates? Once 
you can accomplish step 1, we can move on to step 2.


 STEP 2


Solving Step 1 is compulsory!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http://stackoverflow.com/questions/15311450/my-chat-client-freezes-up-after-beginning-threads

2013-03-09 Thread Owatch
On Mar 9, 6:35 pm, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2013.03.09 09:26, Owatch wrote: Thing is, when I run the program. Nothing 
 happens.

  Can somebody help point out what is wrong? (I've asked questions and 
  researched for 3 days, without getting anywhere, so I did try)

 You defined a thread, but never created or started it. Also, why did you
 subclass threading.Thread? You also mentioned queues, but you didn't use
 them.

 Not tested, but shows the basics:

 import threading
 import queue
 import socket

 def process():
   while alive:
     thing = things_to_process.get()
     # do stuff with the thing here
     things_to_process.task_done()

 alive = True
 host = 'localhost'
 port = 
 things_to_process = queue.Queue()
 process_thread = threading.Thread(target=process)
 process_thread.start()
 sock = socket.socket()
 sock.connect((host, port))
 while alive:
   try:
     data = sock.recv()
   except Exception: # should probably do different things for different
 errors in real code
     alive = False
     sock.close()
     process_thread.join()
     raise
   else:
     things_to_process.put(data)

 --
 CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1

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


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Νίκος Γκρ33κ
mail = form.getvalue('mail')

id what the user types in an html form and click submits. this can be a non 
valid email of course i just check if there is a '@' in the mail address.

But will the mail, gets delivered even if mail's value is invalid?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-09 Thread Roy Smith
In article khg6f3$cfr$1...@reader2.panix.com,
 Grant Edwards invalid@invalid.invalid wrote:

 What I should have said was that there's no way to return to the OS
 memory obtained via calls to malloc() et al.

That's true (for certain values of et al).

 and those are the calls that good C programmers (like the
 maintainers of CPython) use.

Well, there is mmap, which is exposed via the Python mmap module.  
Python doesn't have anything like C++'s placement new, so there's no 
way to use that memory to hold generic Python objects, but you can 
certainly use mmap to allocate a large chunk of memory, use it, and then 
give it back to the OS.  For example:

#!/usr/bin/env python   



import mmap
import time

time.sleep(5)

f = open('my-500-mbyte-text-file')
data = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ)

count = 0
while 1:
line = data.readline()
if not line:
break
count += 1

print count
time.sleep(5)
data.close()
time.sleep(5)

When I run that and watch the process size (like I did with the previous 
example), you can see the process grow when mmap() is called, and shrink 
again when the segment is closed.

I have to admit, in all the years I've been using Python, this is the 
first time I've ever used the mmap module.  Even for long running 
processes, the automatic memory management that Python provides out of 
the box has always been good enough for me.  But, it's nice to know mmap 
is there if I need to do something unusual.
-- 
http://mail.python.org/mailman/listinfo/python-list


pexpect on windows - child process of another child process - quick question

2013-03-09 Thread Z W
Hi All

We have a windows application to install on console mode typing on
cygwin shell app.exe -i console
On Windows process window, we could see this kicks a process named ia
which in turn kicks off ia_launcher to kick off another java.exe
process.
ie

app.exe -- kick off -- ia -- kicks off -- ia_launcher --kicks off
-- java.exe

We like to use pexpect to interact with the ia_launcher process, which
seems to control the stdin/stdout of its own shell window to allow
user to enter responses.
So far, our research shows most examples are related to use of direct
child process, in this case, app.exe process interacting with pexpect.

How do we go about using pexpect to talk to app.exe's grandchild's
shell window ?

We set Don L's expect example where he could set id $spawn_id
between direct child processes but it's still to us how we can
accomplish our goal.

Thanks for your kind help
Sincerely
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are timezone aware and naive datetimes not distinct classes?

2013-03-09 Thread Chris Angelico
On Sun, Mar 10, 2013 at 6:14 AM, Nobody nob...@nowhere.com wrote:
 On Sat, 09 Mar 2013 09:01:17 +1100, Chris Angelico wrote:

 As I see it, a naive datetime simply does not have a timezone.

 The distinction between aware and naive isn't whether the .tzinfo member
 is None, but whether self.utcoffset() returns None (which can occur either
 if self.tzinfo is None or if self.tzinfo.utcoffset(self) returns None).

 IOW, an aware time/datetime can be converted to a UTC time/datetime, a
 naive one can't, although it can still have a timezone which isn't
 referenced to UTC.

I stand corrected. Though the distinction I made in my first paragraph
is still valid: an aware datetime represents an instant in time, a
naive one is a tagged piece of arbitrary data.

On Sun, Mar 10, 2013 at 6:40 AM, Roy Smith r...@panix.com wrote:
 Future scheduled activities (which I assume is what you
 mean by appointments) should be kept in whatever timezone makes sense
 for that activity.

Agreed; and in some specific circumstances, it's even possible to
fight the whole mess of timezones. My online Dungeons and Dragons
group schedules everything on UTC - for example, the server quotes the
current time as Sat 22:26, and I have a session at Sun 02:00, so
anyone can figure out how long until session without worrying about
timezones or Daylight Robbery Time. Of course, that _does_ come at a
cost; mainly it's the USA-based players who get confused (which
surprises me somewhat, tbh).

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


how to get id of a line from his coordonée in tkinter python?

2013-03-09 Thread olsr . kamal
how to get id of a line from his coordonée in tkinter python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any other screenwriters?

2013-03-09 Thread Rick Johnson
On Friday, March 8, 2013 11:36:05 PM UTC-6, richard...@gmail.com wrote:
 Noted. But it seems to be the syntax the screenwriters and
 their programmers have settled on for now. It's all
 working pretty well. Just no Python or command-line
 implementations yet. I didn't post seeking help to make a
 new markdown system for screenwriters. That would surely
 be out of my league.

Well *everything* will perpetually be out of your league until you start 
challenging yourself to learn new things.

 Sorry if I was unclear. Sure. I have several programs like
 this and yes we use them once production starts, but it's
 nice to be able to work in your text editor for as long as
 possible. Faster. More versatility.

I agree.

 So everybody is looking for a fast way to make PDFs in
 screenplay format from simple markdown text.

Well, well. 

This is your golden opportunity Rick. You seem to have found a niche problem 
that needs solving, but more importantly, you have experience as a screen 
writer (and programmer (hobbyist or not)) giving you valuable insight into what 
features can improve the workflow of a simple ASCII markdown syntax. 

And, lucky for you, making the translation from Ruby to Python does not require 
you to become highly proficient with Ruby, NO, once you understand a few key 
differences you can start translating code into something usable.

I think the greatest barrier to learning Ruby is that it has too many ways to 
achieve the same result[1], which is opposite of Python's philosophy[2]. A few 
aspects that can trip you up are:

 * White-space is NOT significant

 * String literals delimited by using single quote chars
   are raw, and string literals delimited by double quote
   chars are not.

 * Module encapsulation is NOT automatic like in Python,
   instead, it must be explicitly declared using module
   [code here] end syntax! Another side effect of this is
   if you write (what you think is a function) in global
   namespace, you are actually writing a method for
   Object, and since Object is inherited by almost
   everything in Ruby, now ALL those subclasses contain your
   new so-called function; Ha! Talk about an introspection
   nightmare! So be sure to encapsulate that code fella.

 * Ruby uses the if-elsif-else progression, whereas Python
   uses if-elif-else. There is also a case statement
   available in Ruby.


 * Object Oriented Programming

Ruby is more Object oriented than Python (which can be a good thing!), for 
instance, no more global function nightmare! Objects have methods and methods 
exist where they should! 

RUBY: sequence.map{|item| item+1}

PYTHON_1: map(lambda item:item+1, sequence)

# via list comprehension:
PYTHON_2: [item+1 for item in sequence]

# via generator expressions!
PYTHON_3: (item+1 for item in sequence)

Hmm, seems old Tim Toady is like a plague of, well... toads!

Another side effect of Rubys strong OOP is that you can intelligently chain:

sequence.map{|x| x+1}.uniq.sort.length

...if you tried that in Python, it would be a mess only a devoted lisper could 
appreciate:

len(set(map(lambda x:x+1, sorted(sequence 

o_O ¡Ay, caramba!


 * Ruby Blocks can be written many *MANY* ways
 

Blocks in ruby will most likely use curly braces like this:

sequence.each{|item| do_something_with(item)}

...but they could also legally use the do..end delimiters like this:

sequence.each do |item| do_something_with(item) end

...or even look exactly like Python code!:

for item in sequence
do_something_with(item)
end

Mama-Mia! That's three ways of accomplishing the exact same thing, and the 
worse part is, these could even be intermixed in the same script file!


 REFERENCES
 

[1] ThereIsMoreThanOneWayToDoIt (affectionately referred to as: Tim Toady)
http://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it

[2] The Python Zen
http://www.python.org/dev/peps/pep-0020/
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are timezone aware and naive datetimes not distinct classes?

2013-03-09 Thread Nobody
On Sat, 09 Mar 2013 14:40:14 -0500, Roy Smith wrote:

 Future scheduled activities (which I assume is what you 
 mean by appointments) should be kept in whatever timezone makes sense 
 for that activity.  For example, I'm on NASA's mailing list to receive 
 alerts when the ISS is going to be visible to the naked eye at my 
 location.  The last one said:
 
 Time: Wed Feb 27 6:17 PM, Visible: 4 min, Max Height: 54 degrees, 
 Appears: W, Disappears: SE
 
 If I wanted to put that on my calendar, I really should convert it to 
 UTC and record it that way.

Indeed; that is an appropriate use of UTC.

 Likewise, let's say I make an appointment to have a phone call with 
 somebody in Caliornia (I'm in New York) at some future date.  I put on 
 my calendar Call with Joe, 5 PM.  Joe puts on his, Call with Roy, 2 
 PM.  The idiots in Albany and/or Sacramento decide to mess with the 
 timezones and one state changes the rules.  We're going to miss our 
 phone call.  Had we both recorded the arranged time in UTC, we'd get to 
 talk to each other.

Maybe. But if the time was chosen so as not to conflict with other
activites, changes to timezone(s) will often result in corresponding
changes to schedules, meaning that one or both parties will no longer be
available at the original UTC time (or even at any time, if both have busy
schedules).

Which is why future scheduled activities which require multiple people
to physically meet at a specific place and time are normally scheduled
in terms of the /de jure/ timezone of that location, as applicable on
that date, rather than in UTC or even a named timezone.

Similarly, the policies of a corporation which operates in multiple
timezones within a single country may dictate times which are common (in
HH:MM terms) to all locations but which are interpreted according to each
location's /de jure/ timezone (e.g. fast food chains' breakfast menus).

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


Re: how to get id of a line from his coordonée in tkinter python?

2013-03-09 Thread Rick Johnson
On Saturday, March 9, 2013 4:46:40 PM UTC-6, olsr@gmail.com wrote:
 how to get id of a line from his coordonée in tkinter python?

Each time you create a canvas item, be it a rectangle, line, circle, or 
whatever..., the id of that object is returned as an integer. All you have to 
do is save the id into a variable.

  rectID = canvas.create_rectangle(...)

Now you can pass that unique id into many of the methods that exist for canvas 
items.

  canvas.delete(rectID)
  canvas.coords(rectID)
  canvas.bbox(rectID)

*Sarcastic Sam quipped*: Rick, not everybody can be as smart as you! What if 
we forgot to save the return value into a variable? Besides, you cannot expect 
us to create a variable to hold *every single* id of *every single* canvas 
object; that would be ridiculous!

Indeed it would Sam. Besides, integer tags are not easy to remember, and they 
are created by the canvas object (which is out of your control). 

But before you throw the computer out the window, be aware that the canvas 
allows you to tag each canvas item by passing one or more strings, using the 
tags=... argument, into the canvas.create_X(args) methods.

py canvas.create_rectangle(0,0,10,10, fill='red', tags='red_rect')
py canvas.coords('red_rect')
(0,0,10,10)

PS: Hopefully you solved that other issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-09 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
 I am in the process of making a pong game in python using the pygame library. 
  My current problem is that when I move the mouse, it turns off as soon as 
 the mouse stops moving.  The way I am doing this is by making the default 
 cursor invisible and using .png files as replacements for the cursor.  
 Perhaps my code would best explain my problem.  I will take help in any way 
 that I can.  Here are the links that contain my code:
 
 
 
 Main class:  http://pastebin.com/HSQzX6h2
 
 Main file (where the problem lies):  http://pastebin.com/67p97RsJ
 
 
 .
 If the links yield nothing, please let me know (agardner...@gmail.com)

I followed your advice, but now I have a drawing problem.  I simply tried 
rewriting the paddle with a black one, but its failing.  I would like to pester 
you fine folks one last time.  The code is here:  http://pastebin.com/gVPPJYWs

I really appreciate your help and am learning from your advice.

Thank you so much, Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-09 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
 I am in the process of making a pong game in python using the pygame library. 
  My current problem is that when I move the mouse, it turns off as soon as 
 the mouse stops moving.  The way I am doing this is by making the default 
 cursor invisible and using .png files as replacements for the cursor.  
 Perhaps my code would best explain my problem.  I will take help in any way 
 that I can.  Here are the links that contain my code:
 
 
 
 Main class:  http://pastebin.com/HSQzX6h2
 
 Main file (where the problem lies):  http://pastebin.com/67p97RsJ
 
 
 
 If the links yield nothing, please let me know (agardner...@gmail.com)

I would like to bother you fine folks one last time!  There are drawing 
problems that I am running into.  The paddle keeps on moving but it doesn't 
rewrite the black paddle.  This is a problem because the paddle just keeps 
leaving a green trail.  The code is here:  http://pastebin.com/gVPPJYWs

I feel as though I am missing something...
-- 
http://mail.python.org/mailman/listinfo/python-list


Building importable _tkinter on Windows

2013-03-09 Thread Terry Reedy
If you have tried to build _tkinter on Windows from the cpython 
repository, and have 'import tkinter' work, please share your 
experience, successful or not. I and another person have both failed.


Following the directions in the devguide (and for one step, 
PCBuild/readme), I did essentially the following.


* download and install TortoiseHG and an svn client (for external.bat)
* download and install c++ 2010 express
* in directory X, clone the python.org hg repository as cpython
* in X/cpython, run Tools/buildbot/external.bat to fetch and compile 
tcl/tk and other external dependencies.
* run visual studio with X/cpython/PCBuild/pcbuild.sln (I just double 
click on the .sln file. Choose c++ 2010 if other compilers are listed.


* build debug version of 3.4 (F7), stored as .../PCBuild/python_d.exe.
This also builds in the same directory things like _bz2_d.pyd and 
_lzma_d.pyd (whose dependencies are also fetched by external.bat) and 
_tkinter_d.pyd, apparently without error. The last is 43 kb. That is 
smaller than the others, but reasonable considering that it just 
forwards calls to tk. My installed 3.3 _tkinter.pyd is 41 kb.


* run python_d.exe. sys.path is
['',
'F:\\Python\\dev\\cpython\\PCbuild\\python34_d.zip',
'F:\\Python\\dev\\cpython\\DLLs',
'F:\\Python\\dev\\cpython\\lib',
'F:\\Python\\dev\\cpython\\PCbuild',  # where _tkinter, etc are
'F:\\Python\\dev\\cpython',
'F:\\Python\\dev\\cpython\\lib\\site-packages']

 import bz2, lzma  # these import _bz2 and _lzma
 import tkinter
Traceback (most recent call last):
  File stdin, line 1, in module
  File F:\Python\dev\cpython\lib\tkinter\__init__.py, line 36, in 
module

from tkinter import _fix
  File F:\Python\dev\cpython\lib\tkinter\_fix.py, line 65, in module
import _tkinter
ImportError: DLL load failed: The specified module could not be found.
[83479 refs, 32096 blocks]

My two hypotheses:

1. There is something wrong with _tkinter_d.pyd in particular such that 
it is not recognized as a dll file. To test this, I renamed my installed 
_tkinter, copied and renamed _tkinter_d, ran installed python 3.3, and 
got a similar error

ImportError: DLL load failed: %1 is not a valid Win32 application.
Perhaps this verifies the hypothesis, perhaps it is due to a mismatch 
between normal builds and debug builds.


2. CPython somehow special-cases the _tkinter import so that it fails in 
the fresh build environment. This seems dubious, but who knows?


Since the Windows buildbots build and test cpython more or less the same 
way, test/test_tkinter should pick up the same problem -- *if* it is 
actually run, but because of some problems with the test suite, I am not 
sure it is, rather than being skipped. Or maybe there is some 
significant small different in the buildbot process.


Does anyone have any idea what else I might do?

I expect to eventually post on pydev or the tracker, but I wanted to 
first try to collect more information here (which I wish more people 
would do).


--
Terry Jan Reedy

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


gmreader - a terminal app for listening to your emails

2013-03-09 Thread Jared Wright
Gmail message test-to-speech reader

I used imaplib along with BeautifulSoup to make this run. It uses system calls 
to run the tts functions. It's all a work in progress, and if you see a bug, 
you are welcome to to make a pull request or open an issue.

https://github.com/jawerty/gmreader
-- 
http://mail.python.org/mailman/listinfo/python-list


pyqt4 qt license

2013-03-09 Thread pitsakis
i want to develop a GUI application that will be sold.
i want to use pyqt4.
can i download and use the GML version during the development and then buy the 
commercial verion beofore i distribute the application ?

commercial version means LGPL? i think i am comfused so please someone clarify 
on versions and licences.

somewhere i also noticed that there is a qt license ? will i need this also ?

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


pyqt4 qt license

2013-03-09 Thread pitsakis
hello,

i want to develop a GUI application that will be sold. 
i want to use pyqt4. 
can i download and use the GPL version during the development and then buy the 
commercial verion beofore i distribute the application ? 

commercial version means LGPL? i think i am comfused so please someone clarify 
on versions and licences. 

somewhere i also noticed that there is a qt license ? will i need this also ? 

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


Re: pyqt4 qt license

2013-03-09 Thread Ioakeim Tellidis
On Sat, Mar 9, 2013 at 9:08 PM, pitsa...@gmail.com wrote:

 hello,

 i want to develop a GUI application that will be sold.
 i want to use pyqt4.
 can i download and use the GPL version during the development and then buy
 the commercial verion beofore i distribute the application ?

 commercial version means LGPL? i think i am comfused so please someone
 clarify on versions and licences.

 somewhere i also noticed that there is a qt license ? will i need this
 also ?

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


I am not sure if this is the right place for clarifying Licences issues.
But I am sure that you are touching a very sensitive issue about how to
mix licenses for commercial products.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyqt4 qt license

2013-03-09 Thread CM
On Mar 9, 9:08 pm, pitsa...@gmail.com wrote:
 hello,

 i want to develop a GUI application that will be sold.
 i want to use pyqt4.
 can i download and use the GPL version during the development and then buy 
 the commercial verion beofore i distribute the application ?

Arguably, yes.  From pyqt4's website:

Yes, you can re-license your application under a commercial license
so long as you have purchased appropriate commercial PyQt licenses
before you start to sell it.

and also:

The availability of the LGPL version of Qt means that it is possible
to evaluate using that and the GPL version of PyQt while still being
able to re-license any code written during an evaluation in a future
closed source application.

 commercial version means LGPL? i think i am comfused so please someone 
 clarify on versions and licences.

There is currently no version of PyQT licensed with LGPL.  They refer
to their commercial license as
their commercial license.

 somewhere i also noticed that there is a qt license ? will i need this also ?

Yes.  PyQT is a wrapper for Python around QT, so you would need both.
QT has, according to the site,
both a GPL and LGPL version of their license.

You can read up on GPL and LGPL by Googling about it, but in a
nutshell, for commercial applications,
of the two, LGPL is what you want.

Do you know about PySide?  It's another wrapper for QT that is
licensed as LGPL and is free software.
I don't know it's current state of development, though.  Last Twitter
update was about a year ago.

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


Re: read and write the same text file

2013-03-09 Thread Steven D'Aprano
On Sat, 09 Mar 2013 10:47:34 -0500, Roy Smith wrote:

 In article c41028f7-e457-4a2b-99f4-c473eaadd...@googlegroups.com,
  iMath redstone-c...@163.com wrote:

 def text_process(file):
 with open(file,'r') as f:
 text = f.read()
 with open(file,'w') as f:
 f.write(replace_pattern.sub('',text))
 
 At a minimum, you need to close the file after you read it and before
 you re-open it for writing.

The with statement automatically does that. When the indented block  -- 
in this case, a single line text = f.read() -- completes, f.close() is 
automatically called.

Technically, this is a property of file objects, not the with statement. 
The with statement merely calls the magic __exit__ method, which for file 
objects closes the file.


 There's a variety of ways you could achieve the same effect.  You might
 open the file once, in read-write mode, read the contents, rewind to the
 beginning with seek(), then write the new contents.  You might also
 write the modified data out to a new file, close it, and then rename it.
 But, open, read, close, open, write, close is the most straight-forward.

All of those techniques are acceptable for quick and dirty scripts. But 
for professional applications, you want something which is resistant to 
data loss. The problems happens when you do this:

1. Read file.
2. Modify data.
3. Open file for writing. # This deletes contents of the file!
4. Write data.
5. Flush data to the hard drive.

Notice that there is a brief time frame where the old data is destroyed, 
but the new data hasn't been saved to the hard drive yet. This is where 
you can get data loss if, say, the power goes off.

So a professional-quality application should do something like this:

1. Read file.
2. Modify data.
3. Open a new file for writing.
4. Write data to this new file.
5. Flush data to the hard drive.
6. Atomically replace the original file with the new file.

Since sensible operating systems promise to be able to replace as a 
single atomic step, guaranteed to either fully succeed or not occur at 
all, this reduces the risk of data corruption or data loss significantly.

Even if you're using an OS that doesn't guarantee atomic replacement 
*cough* Windows *cough* it still decreases the risk of data loss, just 
not as much as we would like.

But having said all that, for normal use, a simple read-write cycle is 
still pretty safe, and it's *much* simpler to get right.



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


Re: pyqt4 qt license

2013-03-09 Thread Michael Torrie
On 03/09/2013 07:08 PM, pitsa...@gmail.com wrote:
 hello,
 
 i want to develop a GUI application that will be sold. i want to use
 pyqt4. can i download and use the GPL version during the development
 and then buy the commercial verion beofore i distribute the
 application ?
 
 commercial version means LGPL? i think i am comfused so please
 someone clarify on versions and licences.

Nope.  Commerical means you buy a royalty-free license to use their
product in a proprietary project.  In other words you buy the right to
use their code in a way that's compatible with your own code's
distribution scheme.

 
 somewhere i also noticed that there is a qt license ? will i need
 this also ?

You must be aware of the licenses of each individual part of the stack
and honor their terms!  This is true of *any* library you use, and code
from *any* source.  Open source does not mean public domain and you
don't automatically have a right to use it in your own project.  If you
are using open source components in a proprietary project, you might
need to consult a lawyer if you are unsure of the use terms you are
dealing with or your obligations under those terms under copyright law.

You have to follow the appropriate license for Qt (LGPL, so no biggy for
you if you don't modify Qt itself), PyQt (GPL only or proprietary
royalty-free), Python itself (not a problem since you aren't modifying
it and you can redistribute it), and any and all Python libraries you
might use.  From what I can tell things in the standard library are
fine, but watch out for third-party libraries.  The licenses are not
always compatible with proprietary code.

As for PyQt, unless you pay for the proprietary, royalty-free license
for PyQT (before or after development), then you have to use the GPL for
your project, since those are the terms the free version of PyQt is
released under.  This is a deliberate choice by the company that makes
it to secure a revenue stream.

There is an alternative to PyQt, PySide, which is under the LGPL and
compatible with a closed-source project.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyqt4 qt license

2013-03-09 Thread D. Xenakis
Please correct me if im wrong..

PySide is LGPL and is free and by using that someone can develop commercial 
(and non commercial) software, while being able at the same to choose between 
both close and open Source.

PyQT4 Commercial Licence costs more than 300 Euro and by using that someone can 
develop commercial software while being again able to choose between both close 
and open Soruce.

PyQT4 GPL Licence is free and by using that someone can develop only 
non-commercial software. What about the source here? Could that be both open 
and close?

Can someone develop a closed source but NON-commercial software, by using PyQT4 
GPL license?

Τη Κυριακή, 10 Μαρτίου 2013 5:31:21 π.μ. UTC+2, ο χρήστης CM έγραψε:
 Yes.  PyQT is a wrapper for Python around QT, so you would need both.
 
 QT has, according to the site,
 
 both a GPL and LGPL version of their license.

If someone used PySide, he should again use in addition one of those 2 above QT 
licences?

Last question: Could someone just buy the PyQT4 commercial licence and use the 
LGPL licence of QT in his CLOSED source commercial software? (Which i believe 
is free :S)

Or does LGPL mean that the source should be open?

Or i should better ask, Does any of those 2 Licenses cost any money? Or they 
are free?


Forgive me for all these questions im very interested in this topic too.
THX 4 your time!!
Tellidis your Greek? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Νίκος Γκρ33κ
Any ideas why the mail never gets delivered?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyqt4 qt license

2013-03-09 Thread Vito De Tullio
D. Xenakis wrote:

 Can someone develop a closed source but NON-commercial software, by using
 PyQT4 GPL license?

no, by definition of GPL: if you are using a GPL library, you must 
distribute your software as GPL.

(the GPL does not care about commercial / non commercial)

http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL

-- 
ZeD

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


Re: pyqt4 qt license

2013-03-09 Thread Michael Torrie
On 03/09/2013 09:45 PM, Vito De Tullio wrote:
 D. Xenakis wrote:
 
 Can someone develop a closed source but NON-commercial software, by using
 PyQT4 GPL license?
 
 no, by definition of GPL: if you are using a GPL library, you must 
 distribute your software as GPL.
 
 (the GPL does not care about commercial / non commercial)
 
 http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL

Just to be clear here, the GPL isn't a magical license.  It doesn't
arbitrarily infect your code and force you to use the GPL on your own
code.  And no matter what license you use, you can re-license your code
later under any terms you wish, since you own the copyright on the code.

Here's the vital part: The moment you distribute your code, if you use a
GPL library, then unless you also release your code under the GPL also,
you are now in a copyright violation situation.  You have three options:

1. License your code in a compatible way so that you're following the
terms of the open source license the library you are using asks of you.
 IE release your source code under the terms of the GPL.

2. Remove the GPL'd library and either implement the lost functionality
yourself (also know as write your own dang code), or replace the GPL'd
library with an equivalent library under a different, compatible
license.  In the case of PyQt, this could be PySide, or maybe you decide
to use a completely different GUI toolkit.

3. Negotiate a proprietary license with the copyright holder (IE buy the
proprietary, royalty-free license from PyQt's authors.

If you are in a position where you have violated copyright, failure to
remedy it in a timely manner can cause you to be financially liable to
the copyright holders of the code you are mis-using.

Now, if you develop a program using PyQt and distribute it under the
terms of the GPL, that does not mean you have to keep your code under
the GPL.  You can close your source at any time and use, say, PySide
instead.  But any code you already distributed under the GPL remains in
the wild (supposing someone has a copy) under the GPL terms, even if
newer versions of your software adopt a new license.




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


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Michael Torrie
On 03/09/2013 02:25 PM, Νίκος Γκρ33κ wrote:
 mail = form.getvalue('mail')
 
 id what the user types in an html form and click submits. this can be
 a non valid email of course i just check if there is a '@' in the
 mail address.
 
 But will the mail, gets delivered even if mail's value is invalid?

Who knows. You haven't specified how you are sending e-mail.  Likely, if
an e-mail address is invalid, python still happily hands it off to your
designated mail server or local MTA (mail transfer agent--could be
sendmail).  What happens there depends entirely on the policies of the
mail server or MTA you are using.

If python is trying to use sendmail, then probably the process would
just fail and return some sort of error code.  But you will need to
check on the documentation of whatever e-mail library you are using in
Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Νίκος Γκρ33κ
Τη Κυριακή, 10 Μαρτίου 2013 7:07:25 π.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:
 On 03/09/2013 02:25 PM, Νίκος Γκρ33κ wrote:
 
  mail = form.getvalue('mail')
 
  
 
  id what the user types in an html form and click submits. this can be
 
  a non valid email of course i just check if there is a '@' in the
 
  mail address.
 
  
 
  But will the mail, gets delivered even if mail's value is invalid?
 
 
 
 Who knows. You haven't specified how you are sending e-mail.  Likely, if
 
 an e-mail address is invalid, python still happily hands it off to your
 
 designated mail server or local MTA (mail transfer agent--could be
 
 sendmail).  What happens there depends entirely on the policies of the
 
 mail server or MTA you are using.
 
 
 
 If python is trying to use sendmail, then probably the process would
 
 just fail and return some sort of error code.  But you will need to
 
 check on the documentation of whatever e-mail library you are using in
 
 Python.

I'am using smtplib and i ahve contacted the hostgator administrators and they 
say that Sendmail is ebaled for my reseller account.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Steven D'Aprano
On Sat, 09 Mar 2013 20:42:03 -0800, Νίκος Γκρ33κ wrote:

 Any ideas why the mail never gets delivered?

What do the mail logs say?

Can you send email using this mail server from Thunderbird, or does it 
fail there too?

My wild guess is that the mail server is properly rejecting mail because 
you are trying to send to it without an account.


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


Re: This mail never gets delivered. Any ideas why?

2013-03-09 Thread Νίκος Γκρ33κ
Τη Κυριακή, 10 Μαρτίου 2013 7:56:45 π.μ. UTC+2, ο χρήστης Steven D'Aprano 
έγραψε:

 My wild guess is that the mail server is properly rejecting mail because 
 you are trying to send to it without an account.

Account 'support(-at-)hostgator.com' exists. It's the recipient mail address 
which is my personal address fot my web hosting business.

In TB yes i can read email via SSL witohut any problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17388] Providing invalid value to

2013-03-09 Thread Chris Tandiono

New submission from Chris Tandiono:

Currently, random.sample(population, k) raises a ValueError if k is out of the 
range of [0, len(population)], inclusive. However, the message says Sample 
larger than population even when the real problem is that k  0. The attached 
patch fixes that.

The problem exists in all versions of Python that have the random.sample 
function.

I think I should be adding tests for this, but I don't know in what existing 
file, if any, this test should go into.

--
components: Library (Lib)
files: random_sample.patch
keywords: patch
messages: 183808
nosy: Chris.Tandiono
priority: normal
severity: normal
status: open
title: Providing invalid value to
type: behavior
versions: 3rd party, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 
3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file29354/random_sample.patch

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



[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Chris Tandiono

Changes by Chris Tandiono chris.tandi...@gmail.com:


--
title: Providing invalid value to - Providing invalid value to random.sample 
can result in incorrect error message

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



[issue15873] datetime cannot parse ISO 8601 dates and times

2013-03-09 Thread Anders Hovmöller

Anders Hovmöller added the comment:

Éric Araujo: absolutely. Although I think my code can be improved (speed wise, 
elegance, etc) since I just wrote it quickly a weekend :)

--

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



[issue17385] Use deque instead of list the threading.Condition waiter queue

2013-03-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't think you need slicing if you rewrite the patch in another way, e.g.:

for i in range(n):
try:
waiter = __waiters.popleft()
except IndexError:
break
waiter.release()

I think this is safe, since notify() must be called with the lock held: another 
thread shouldn't be able to mutate the waiters list in the meantime.

As for notify_all(), it could be optimized to swap the internal list with an 
empty one: there's no need to pop the waiters one by one.

--
nosy: +neologix

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



[issue17389] Optimize Event.wait()

2013-03-09 Thread Antoine Pitrou

New submission from Antoine Pitrou:

It should be possible to optimize threading.Event.wait() to not acquire the 
condition when the event is already set. Patch attached.

Without patch:

$ ./python -m timeit -s import threading; e = threading.Event(); e.set() 
e.wait()
100 loops, best of 3: 0.466 usec per loop

With patch:

$ ./python -m timeit -s import threading; e = threading.Event(); e.set() 
e.wait()
1000 loops, best of 3: 0.19 usec per loop

--
components: Library (Lib)
files: event_wait.patch
keywords: patch
messages: 183811
nosy: neologix, pitrou, sbt
priority: normal
severity: normal
stage: patch review
status: open
title: Optimize Event.wait()
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file29355/event_wait.patch

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



[issue17340] Handle malformed cookie

2013-03-09 Thread karl

karl added the comment:

Yes the new RFC has been written by Adam Barth who wanted to describe things 
matching the reality of HTTP and servers/browsers issues.

--

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



[issue17299] Test cPickle with real files

2013-03-09 Thread Aman Shah

Aman Shah added the comment:

I have updated the patch for test_cpickle.py . Also, I would like to help out 
in creating mixins for the 3 but, it would be helpful if you can explain it in 
a bit more detail. What is the problem in using the existing pickletester.py??

--
Added file: http://bugs.python.org/file29356/test_cpickle_patch

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



[issue10595] Adding a syslog.conf reader in syslog

2013-03-09 Thread Ankur Ankan

Changes by Ankur Ankan ankuran...@gmail.com:


--
nosy: +Ankur.Ankan

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't understand why you must put the socket in non-blocking mode for 
sendfile().
Also I think the support code (_use_send() / _use_sendfile()) should be 
factored out somewhere. There could even be a socket.sendfile() method with the 
appropriate fallbacks?

--

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



[issue15518] Provide test coverage for filecmp.dircmp.report methods.

2013-03-09 Thread Ankur Ankan

Changes by Ankur Ankan ankuran...@gmail.com:


--
nosy: +Ankur.Ankan

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



[issue17375] Add docstrings to methods in the threading module

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Raymond - which patch is it? You didn't specify the contributor in the commit. 
What about the duplicate issue #12768 where someone also worked to supply a 
patch? 

Also, you've only committed this to 2.7; why?

--

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



[issue16576] ctypes: structure with bitfields as argument

2013-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0acd9408b6f1 by Eli Bendersky in branch '3.2':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/0acd9408b6f1

New changeset bfc159f8e4b4 by Eli Bendersky in branch '3.3':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/bfc159f8e4b4

New changeset 502624235c7b by Eli Bendersky in branch 'default':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/502624235c7b

--
nosy: +python-dev

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



[issue16575] ctypes: unions as arguments

2013-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0acd9408b6f1 by Eli Bendersky in branch '3.2':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/0acd9408b6f1

New changeset bfc159f8e4b4 by Eli Bendersky in branch '3.3':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/bfc159f8e4b4

New changeset 502624235c7b by Eli Bendersky in branch 'default':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/502624235c7b

--
nosy: +python-dev

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



[issue16576] ctypes: structure with bitfields as argument

2013-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eece32440a52 by Eli Bendersky in branch '2.7':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/eece32440a52

--

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



[issue16575] ctypes: unions as arguments

2013-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset eece32440a52 by Eli Bendersky in branch '2.7':
Add warning in ctypes documentation for #16575 and #16576
http://hg.python.org/cpython/rev/eece32440a52

--

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



[issue11367] xml.etree.ElementTree.find(all): docs are wrong

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Henrik, this patch fails to apply to 3.2

applying issue11367_branch32.patch
patching file Doc/library/xml.etree.elementtree.rst
Hunk #1 FAILED at 411
1 out of 1 hunks FAILED -- saving rejects to file 
Doc/library/xml.etree.elementtree.rst.rej
patching file Lib/xml/etree/ElementTree.py
Hunk #1 FAILED at 704
Hunk #2 FAILED at 725
Hunk #3 FAILED at 750
3 out of 3 hunks FAILED -- saving rejects to file 
Lib/xml/etree/ElementTree.py.rej
abort: patch failed to apply


I suspect this may be because of line endings. Are you generating the patches 
on a Windows machine? All patches to Python should be strictly in Unix format 
(LF for line ending, not CR LF). Can you configure your hg client and / or 
editor to do this?

I haven't touched Windows for some time but IIRC TortoiseHg does the right 
thing if your file is proper. In other words, perhaps it's the editor's fault. 
Your editor should not insert Windows line-endings into a Unix-y file (which 
Doc/library/xml.etree.elementtree.rst is).

--

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



[issue17359] python modules.zip is not documented

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Marc-Andre,  Can this issue be closed or are the docs lacking in some way?

--

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



[issue17138] XPath error in xml.etree.ElementTree

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Gutzwiller, the [position] syntax means the Nth child *of its parent*. Since 
you placed the second h1 into p, it's the first child of its parent. So the 
library's behavior is correct here. Note:

 [e.text for e in xml.findall('.//h1[1]')]
['1', '2']

--
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue15518] Provide test coverage for filecmp.dircmp.report methods.

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Chris Calloway, would you like to pursue this issue further?

--

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



[issue16954] Add docstrings for ElementTree module

2013-03-09 Thread Eli Bendersky

Eli Bendersky added the comment:

Thanks David, the patch looks good. I will commit it with some slight 
modifications and touch-ups shortly.

The issue of C extension docstrings vs. Python docstrings is an interesting 
one. It's a shame that help() shows empty strings, and it's a shame to 
copy-paste. What do other modules do? It may also be worth asking in python-dev 
or the docs mailing list and hear suggestions from other developers.

--

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



[issue16954] Add docstrings for ElementTree module

2013-03-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f27d7c1eac4d by Eli Bendersky in branch 'default':
Issue #16954: Add docstrings for ElementTree
http://hg.python.org/cpython/rev/f27d7c1eac4d

--
nosy: +python-dev

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



[issue11367] xml.etree.ElementTree.find(all): docs are wrong

2013-03-09 Thread anatoly techtonik

anatoly techtonik added the comment:

You can use patch.py utility from 
http://python-patch.googlecode.com/svn-history/trunk/patch.py to apply patch 
that doesn't have this CRLF problem.

--

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

 I don't understand why you must put the socket in 
 non-blocking mode for sendfile().

I did that mainly because I'm using select() / poll() and it seems kind of 
natural to set the socket in non-blocking mode (proftpd does the same).
I'm not sure whether it actually makes any difference though (on Linux it works 
either way, blocking or not).
I'm removing the non-blocking mode in the new attached patch. We can take take 
a look at the buildbots later and see how they behave.

 Also I think the support code (_use_send() / _use_sendfile()) should be 
 factored out somewhere.

Agreed and turned them into methods.

 There could even be a socket.sendfile() method with the appropriate fallbacks?

Perhaps. The only thing which is not clear is how to deal with blocking vs. 
non-blocking sockets.
Also, Windows should also be covered and expose TransmitFile. 
It's probably better to discuss this elsewhere.

--
Added file: http://bugs.python.org/file29357/ftplib-sendfile4.patch

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

  I don't understand why you must put the socket in 
  non-blocking mode for sendfile().
 
 I did that mainly because I'm using select() / poll() and it seems
 kind of natural to set the socket in non-blocking mode (proftpd does
 the same).

But why do you need to use select() / poll() ? Can't you just call
sendfile() right from the start?

--

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



[issue17370] PEP should note if it has been superseded

2013-03-09 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Mar 09, 2013, at 03:30 AM, Terry J. Reedy wrote:

I think you are, in effect, asking for expansion of the 'PEP Header Preamble'
section of PEP-0001. I have added some of the PEP editors listed in the PEP
as nosy. I will let them decide if this should be discussed elsewhere.

Looks like Benjamin just changed Replaced-By with Superseded-By in PEP 1 and
Replaced with Superseded as a Status.  He also updated a bunch of PEPs with
the new headers, including 333.

He probably should have discussed this with the other PEP editors beforehand,
but in retrospect, it seems fine.

I guess that means you're requesting a new header such as 'Related' which
would contain a list of PEP numbers?  Usually we just put those in the
references (and it's perfectly fine to update a PEP after it's final with new
references - that's why we have a version control system. :)

--

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Because otherwise sendfile() fails with EAGAIN many times before sending any 
actual data. 
select() / poll() make sure the while loop awakens only when the socket is 
ready to be written (as opposed to continuously catching EAGAIN and wait for 
sendfile() to succeed).

--

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



[issue17343] Add a version of str.split which returns an iterator

2013-03-09 Thread Gregory P. Smith

Gregory P. Smith added the comment:

It'd perhaps have been better if things like memoryview were never exposed to 
the user at all as a distinct type and became an internal implementation detail 
behind PyBytes and PyUnicode objects (they could hold a reference to something 
else or collapse that down to their own copy on their own terms, up to the 
particulars of the Python VM).

Anyways, the above is getting off topic for this issue.  I retract my 
memoryview suggestion; that belongs in its own issue.

An iterating version of str.split is indeed hard to add today IFF we are 
against a str.itersplit() method name or against an optional keyword only 
argument that'd cause split(iterator=True)'s return type to potentially be 
different.

--

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Because otherwise sendfile() fails with EAGAIN many times before
 sending any actual data. 

EAGAIN on a blocking fd? Is it documented somewhere?
The Linux man page for sendfile() says:

   EAGAIN Nonblocking I/O has been selected using O_NONBLOCK and the
write would block.

FreeBSD apparently says something similar:

 [EAGAIN]   The socket is marked for non-blocking I/O and not all
data was sent due to the socket buffer being filled.
If specified, the number of bytes successfully sent
will be returned in *sbytes.

--

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



[issue14146] IDLE: source line in editor doesn't highlight when debugging

2013-03-09 Thread Roger Serwy

Roger Serwy added the comment:

I think it's a problem on Tk on Windows. The painting of the selection 
highlight goes away when a window loses focus.

--

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

I see. Well, what I'm experiencing right now if I remove the select() / poll() 
call is a sequence of EAGAIN errors alternated by successful sendfile() calls.  
Either the man page is wrong or I'm missing something.

--

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



[issue13564] ftplib and sendfile()

2013-03-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 I see. Well, what I'm experiencing right now if I remove the
 select() / poll() call is a sequence of EAGAIN errors alternated by
 successful sendfile() calls.  
 Either the man page is wrong or I'm missing something.

Weird. I guess it would be nice to dig a bit more :-)

--

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



[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +mark.dickinson, rhettinger
versions:  -3rd party, Python 2.6, Python 3.1, Python 3.5

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



[issue17388] Providing invalid value to random.sample can result in incorrect error message

2013-03-09 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This seems like a silly criticism to me.  A negative value will almost never be 
the cause of this exception.

That said, I'll tweak the message at some point.

--
assignee:  - rhettinger
priority: normal - low

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



[issue17384] test_logging failures on Windows

2013-03-09 Thread Ezio Melotti

Ezio Melotti added the comment:

Confirmed, thanks for fixing this!

--
stage: needs patch - committed/rejected

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



  1   2   >