Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Marko Rauhamaa
Gregory Ewing :

> I didn't think that using a custom mapping object for globals was
> officially supported. Has that changed?

The documentation is a bit vague about it:

   If only globals is provided, it must be a dictionary, which will be
   used for both the global and the local variables. If globals and
   locals are given, they are used for the global and local variables,
   respectively. If provided, locals can be any mapping object.

Now, if you define:

   class Namespace(dict):
   ...

A Namespace *is* a dict[ionary] in the classic OOP sense.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suds 4.1 Beta Assertion Failure

2014-06-12 Thread dieter
1stpo...@gmail.com writes:
> ...
> I have another issue.  When I make the call to return data apparently the 
> result set is too big for suds and I get a MemoryError.
>
> Here is my code snippet:
> print 'executing SQL Query:',len(logicalSQL)
> 
> executionOptions={'async':False,'maxRowsPerPage':50,'refresh':True,'presentationInfo':False,'type':'Q1'}
> XMLservice=obiclient.service['XmlViewService']
> result=XMLservice.executeSQLQuery(logicalSQL,'SAWRowsetData',executionOptions,sessionid)
>
> When I run it I get:
> executing SQL Query: 5968
> Traceback (most recent call last):
>   File "C:\temp\obiee\obieetest.py", line 105, in 
> 
> result=XMLservice.executeSQLQuery(logicalSQL,'SAWRowsetData',executionOptions,sessionid)
>   File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
>   File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
>   File "build\bdist.win32\egg\suds\client.py", line 643, in send
>   File "build\bdist.win32\egg\suds\transport\https.py", line 64, in send
>   File "build\bdist.win32\egg\suds\transport\http.py", line 79, in send
>   File "C:\Python27\lib\socket.py", line 358, in read
> buf.write(data)
> MemoryError: out of memory

There is not much "suds" can do with regard to this. In principle,
it could write to a temporary file - but its purpose is to present
the webservice result as a collection of Python objects - and
they, too, require memory in the same order.

Thus, you have the following options:

  *  learn how to limit the amount of data, the webservice provides
  *  give your system (its processes) more memory
  *  do not use "suds" but process the incoming data incrementally
 (avoiding the build of the intermediate collection of Python objects).

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


Re: Python deepcopy to while statement

2014-06-12 Thread hito koto
2014年6月13日金曜日 12時47分19秒 UTC+9 hito koto:
> Hi, all
> 
> 
> 
> I want to make the function use while statement,and  without a deepcopy 
> functions.
> 
> 
> 
> this is my use deepcopy  function correct codes, So, how can i to do a 
> different way  and use while statement:
> 
> 
> 
> def foo(x):
> 
> if not isinstance(x, list):
> 
> return x
> 
> return [foo(y) for y in x]


I write this code but this is not copy:
maybe noe more write while statements: but i can't.

def foo(x):
y = []
i = len(x)-1
while i >= 0:
y.append(x[i])
i -= 1
return y
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python deepcopy to while statement

2014-06-12 Thread hito koto
2014年6月13日金曜日 12時47分19秒 UTC+9 hito koto:
> Hi, all
> 
> 
> 
> I want to make the function use while statement,and  without a deepcopy 
> functions.
> 
> 
> 
> this is my use deepcopy  function correct codes, So, how can i to do a 
> different way  and use while statement:
> 
> 
> 
> def foo(x):
> 
> if not isinstance(x, list):
> 
> return x
> 
> return [foo(y) for y in x]

I write this code but this is not copy:
 maybe have to write one more the while statements: but i can't.
 

 def foo(x):
 y = []> 
 i = len(x)-1
 while i >= 0:
 y.append(x[i])
 i -= 1
 return y
-- 
https://mail.python.org/mailman/listinfo/python-list


C-API proper initialization and deallocation of subclasses

2014-06-12 Thread ptb
Hello all,

I decided to play around with the C-API and have gotten stuck.  I went through 
the Shoddy example 
(https://docs.python.org/3/extending/newtypes.html#subclassing-other-types) in 
the docs and tried to extend it by adding a method which creates and returns a 
shoddy instance.  I dug around to find ways to allocate and initialize my 
shoddy instance and that seems to work well.  However, I get segfaults when I 
try to delete my instance.  The code is in the gist: 
https://gist.github.com/pbrady/f2daf50761e458bbe44a

The magic happens in the make_a_shoddy function.

Here's a sample session (Python 3.4.1)

>>> from shoddy import make_a_shoddy()
>>> shd = make_a_shoddy()
tup build
shd allocated
list style allocation successful
Py_SIZE(list) : 5
Py_SIZE(shoddy) : 5
>>> type(shd)

>>> shd[:]
[1, 2, 3, 4, 5]
>>> shd.increment()
1
>>> shd.increment()
2
>>> del shd
Segmentation fault (core dumped)

This happens even if I don't set the destructor.  Any ideas on what I am doing 
wrong?

Thanks,
Peter.

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


Python deepcopy to while statement

2014-06-12 Thread hito koto
Hi, all

I want to make the function use while statement,and  without a deepcopy 
functions.

this is my use deepcopy  function correct codes, So, how can i to do a 
different way  and use while statement:

def foo(x):
if not isinstance(x, list):
return x
return [foo(y) for y in x]



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


Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Fri, 13 Jun 2014 03:18:00 +1000, Chris Angelico wrote:

> On Fri, Jun 13, 2014 at 3:04 AM, Steven D'Aprano
>  wrote:
[...]
>> Take three numbers, speeds in this case, s1, s2 and c, with c a strict
>> upper-bound. We can take:
>>
>> s1 < s2 < c
>>
>> without loss of generality. So in this case, we say that s2 is greater
>> than s1:
>>
>> s2 > s1
>>
>> Adding the constant c to both sides does not change the inequality:
>>
>> c + s2 > c + s1
> 
> As long as we accept that this is purely in a mathematical sense. Let's
> not get into the realm of actual speeds greater than c.

Well, yes, it is in the mathematical sense, and it doesn't require any 
actual physical thing to travel at faster than light speed. There is no 
implication here that there is something travelling at (c + s1). It's 
just a number.

But note that even in *real* (as opposed to science fiction, or 
hypothetical) physics, you can have superluminal speeds. Both the phase 
velocity and group velocity of a wave may exceed c; the closing velocity 
of two objects approaching each other is limited to 2c. Distant galaxies 
are receding from us at greater than c. There are other situations where 
some measurable effect can travel faster than c, e.g. the superluminal 
spotlight effect.

https://en.wikipedia.org/wiki/Faster-than-light




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: http://bugs.python.org/issue19495 timeit enhancement

2014-06-12 Thread Cameron Simpson

On 13Jun2014 00:44, Steven D'Aprano  
wrote:

On Fri, 13 Jun 2014 00:35:43 +0100, Mark Lawrence wrote:

The request is for a class within timeit that allows you to test code
inside a with block.  It strikes me as being useful but there's only one
response on the issue, albeit a positive one.  If others here think this
would be a useful addition I'll see if I can take this forward, unless
there are any timeit fans lurking who'd like to run with it themselves.


I have a Stopwatch() context manager which I have been using for a long
time, very successfully. There's an early version here:

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

I'll clean it up and submit it on the bug tracker.


And I have a LogTimer context manager that emits a log message when a with 
suite exceeds a threshold.


I'm sure it is far cruder and limited than Steven's; I'm mentioning it in 
support of the use case.


Cheers,
Cameron Simpson 

1993 Explorer - Cage? Hell, it's a prison. - Will Hartung vfr...@netcom.com
--
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Rustom Mody
On Thursday, June 12, 2014 10:48:00 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Jun 13, 2014 at 3:04 AM, Steven D'Aprano
> > Take three numbers, speeds in this case, s1, s2 and c, with c a strict
> > upper-bound. We can take:
> > s1 < s2 < c
> > without loss of generality. So in this case, we say that s2 is greater
> > than s1:
> > s2 > s1
> > Adding the constant c to both sides does not change the inequality:
> > c + s2 > c + s1

> As long as we accept that this is purely in a mathematical sense.
> Let's not get into the realm of actual speeds greater than c.

You got a keen eye Chris -- didn't notice that!
And captures my point better than my long-winded attempts

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


Re: http://bugs.python.org/issue19495 timeit enhancement

2014-06-12 Thread Steven D'Aprano
On Fri, 13 Jun 2014 00:35:43 +0100, Mark Lawrence wrote:

> The request is for a class within timeit that allows you to test code
> inside a with block.  It strikes me as being useful but there's only one
> response on the issue, albeit a positive one.  If others here think this
> would be a useful addition I'll see if I can take this forward, unless
> there are any timeit fans lurking who'd like to run with it themselves.

I have a Stopwatch() context manager which I have been using for a long 
time, very successfully. There's an early version here:

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

I'll clean it up and submit it on the bug tracker.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Gregory Ewing

Robert Lehmann wrote:
I have noticed there is a slight asymmetry in the way the interpreter 
(v3.3.5, reproduced also in v3.5.x) loads and stores globals.  While 
loading globals from a custom mapping triggers __getitem__ just fine, 
writing seems to silently ignore __setitem__.


I didn't think that using a custom mapping object for
globals was officially supported. Has that changed?

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Gregory Ewing

Pedro Izecksohn wrote:

  Thank you Greg. Your second approach works and the script became:


That's not really what I meant; doing it that way,
you're still incurring the overhead of a tk canvas
object for each point that you draw. However, if
there are only 250 points or so, it might not matter.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: idle glitch while building python 3.4 from sources

2014-06-12 Thread Terry Reedy

On 6/12/2014 4:35 PM, kfs...@gmail.com wrote:

I just upgraded to Python 3.4.1 AMD64 for Windows 7 using the binaries,


Upgraded from what to what with what? Which binaries? Details matter.


and this appears to have affected the Windows binary distribution.



 osmith@WOTSIT /c/Python34/Lib/idlelib
 $ python idle.py
 ** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **


Try idle.bat
---

Running idle with binaries you compile from the sources, using the VS 
project files in pcbuild, is a different story. If you are actually 
doing that, read the devguide and ask me for the missing detail.


--
Terry Jan Reedy

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


http://bugs.python.org/issue19495 timeit enhancement

2014-06-12 Thread Mark Lawrence
The request is for a class within timeit that allows you to test code 
inside a with block.  It strikes me as being useful but there's only one 
response on the issue, albeit a positive one.  If others here think this 
would be a useful addition I'll see if I can take this forward, unless 
there are any timeit fans lurking who'd like to run with it themselves.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Pedro Izecksohn
- Original Message -

> From: Gregory Ewing
> To: python-list@python.org
> Cc: 
> Sent: Thursday, June 12, 2014 8:38 AM
> Subject: Re: Lines on a tkinter.Canvas
> 
> Pedro Izecksohn wrote:
>>  The Canvas' method create_line turns on at least 2 pixels. But I want 
> to turn
>>  on many single pixels on a Canvas.
> 
> You could try using a 1x1 rectangle instead.
> 
> However, be aware that either of these will use quite a
> lot of memory per pixel. If you are drawing a very large
> number of pixels, this could cause performance problems.
> In that case, you might want to use a different approach,
> such as creating an image and telling the canvas to display
> the image.

  Thank you Greg. Your second approach works and the script became:

#!/usr/bin/python3

import tkinter as tk

BITMAP = '''
#define im_width 1
#define im_height 1
static char im_bits[] = {
0xff
};
'''

class Point ():
  def __init__ (self, x, y):
    self.x = x
    self.y = y

class Board (tk.Frame):
  def __init__ (self, bg, dimensions):
    tk.Frame.__init__ (self, tk.Tk())
    self.pack()
    self.canvas = tk.Canvas (self, bd = 0, bg = bg, width = dimensions.x, 
height = dimensions.y)
    self.canvas.pack (side = "top")
    self.objects_drawn = []
  def drawLine (self, pa, pb, color):
    self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill = color)
  def drawPoint (self, p, color):
    bitmap = tk.BitmapImage (data=BITMAP, foreground = color)
    self.objects_drawn.append (bitmap)
    self.canvas.create_image (p.x, p.y, image = bitmap)

dimensions = Point (500, 500)
board = Board ('black', dimensions)
color = 'red'
p = Point (0, 250)
while (p.x < dimensions.x):
  board.drawPoint (p, color)
  p.x += 1
pa = Point (0, 350)
pb = Point (499, 350)
board.drawLine (pa, pb, color)
board.mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Pedro Izecksohn
- Original Message -

> From: Gregory Ewing
> To: python-list@python.org
> Sent: Thursday, June 12, 2014 8:38 AM
> Subject: Re: Lines on a tkinter.Canvas
> 
> Pedro Izecksohn wrote:
>>  The Canvas' method create_line turns on at least 2 pixels. But I want 
> to turn
>>  on many single pixels on a Canvas.
> 
> You could try using a 1x1 rectangle instead.

pedro@microboard:~/programming/python/tk/canvas$ diff old/testing.001.py 
testing.py
19c19
< self.canvas.create_line (p.x, p.y, p.x, p.y, fill = color)
---
> self.canvas.create_rectangle (p.x, p.y, p.x, p.y, fill = color)

  The result that I got is: The line drawn by it is not shown.

> However, be aware that either of these will use quite a
> lot of memory per pixel. If you are drawing a very large
> number of pixels, this could cause performance problems.
> In that case, you might want to use a different approach,
> such as creating an image and telling the canvas to display
> the image.

  I did not try this yet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: idle glitch while building python 3.4 from sources

2014-06-12 Thread kfsone
I just upgraded to Python 3.4.1 AMD64 for Windows 7 using the binaries, and 
this appears to have affected the Windows binary distribution.

osmith@WOTSIT /c/Python34/Lib/idlelib
$ python idle.py
** IDLE can't import Tkinter.  Your Python may not be configured for Tk. **

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


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Pedro Izecksohn
  As Peter Otten did not see the same result that I saw, I prepared an image 
that shows the result on my notebook:
http://izecksohn.com/pedro/python/canvas/tk_window.xcf
  For those that might not know: xcf is the Gimp's file format.


- Original Message -
> From: Peter Otten
> To: python-list@python.org
> Sent: Thursday, June 12, 2014 4:02 AM
> Subject: Re: Lines on a tkinter.Canvas
> 
> Pedro Izecksohn wrote:
> 
>>  The code available from:
>>  http://izecksohn.com/pedro/python/canvas/testing.py
>>  draws 2 horizontal lines on a Canvas. Why the 2 lines differ on thickness
>>  and length?
>> 
>>  The Canvas' method create_line turns on at least 2 pixels. But I want 
> to
>>  turn on many single pixels on a Canvas. How should I do this? Canvas has
>>  no method create_pixel or create_point.
> 
>>  #!/usr/bin/python3
>> 
>>  import tkinter as tk
>> 
>>  class Point ():
>>    def __init__ (self, x, y):
>>      self.x = x
>>      self.y = y
>> 
>>  class Board (tk.Frame):
>>    def __init__ (self, bg, dimensions):
>>      tk.Frame.__init__ (self, tk.Tk())
>>      self.pack()
>>      self.canvas = tk.Canvas (self, bd = 0, bg = bg, width = dimensions.x, 
> height = dimensions.y)
>>      self.canvas.pack (side = "top")
>>    def drawLine (self, pa, pb, color):
>>      self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill = color)
>>    def drawPoint (self, p, color):
>>      self.canvas.create_line (p.x, p.y, p.x, p.y, fill = color)
>> 
>>  dimensions = Point (500, 500)
>>  board = Board ('black', dimensions)
>>  color = 'red'
>>  p = Point (0, 250)
>>  while (p.x < dimensions.x):
>>    board.drawPoint (p, color)
>>    p.x += 1
>>  pa = Point (0, 350)
>>  pb = Point (499, 350)
>>  board.drawLine (pa, pb, color)
>>  board.mainloop()
> 
> I just tried your script, and over here the line drawn with
> 
>>    def drawLine (self, pa, pb, color):
>>      self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill = color)
> 
> has a width of 1 pixel and does not include the end point. Therefore the 
> "line" drawn with
> 
>>    def drawPoint (self, p, color):
>>      self.canvas.create_line (p.x, p.y, p.x, p.y, fill = color)
> 
> does not show up at all. You could try to specify the line width explicitly:
> 
>    def drawPoint (self, p, color):
>      self.canvas.create_line (p.x, p.y, p.x+1, p.y, fill=color, width=1)
> 
> If that doesn't work (or there's too much overhead) use pillow to 
> prepare an 
> image and show that.
> 
> Another random idea: if you have a high resolution display your OS might 
> blow up everything. In that case there would be no fix on the application 
> level.
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Gene Heskett
On Thursday 12 June 2014 13:18:00 Chris Angelico did opine
And Gene did reply:
> On Fri, Jun 13, 2014 at 3:04 AM, Steven D'Aprano
> 
> > I'm saying that, whatever the practical engineering limits turn out
> > to be, we're unlikely to be close to them, and therefore there are
> > very likely to be many and massive efficiency gains to be made in
> > computing.
> 
> And this I totally agree with. The limits of physics are so incredibly
> far from where we now are that we can utterly ignore them; the limits
> we face are generally engineering (with the exception of stuff
> designed for humans to use, eg minimum useful key size is defined by
> fingers and not by what we can build).
> 
> ChrisA

Thats a bit too blanketish a statement, we do see it in the real world.  
Some of the electronics stuff we've been using for nearly 50 years 
actually runs into the e=MC^2 effects, and it affects their performance in 
pretty deleterious ways.

A broadcast power klystron, like a 4KM100LA, which is an electron beam 
device that does its amplifying by modulating the velocity of an electron 
beam which is being accelerated by nominally a 20,000 volt beam supply.
But because of the beam speed from that high a voltage brings in 
relativity effects from e=MV^2 mass of the electrons in that beam, an 
equal amount of energy applied to speed it up does not get the same 
increase in velocity as that same energy applied to slow it down decreases 
it.  This has the net effect of making the transit time greater when under 
high power drive conditions such as the sync pulses of the now out of 
style NTSC signal.  The net result is a group delay characteristic that is 
uncorrectable when the baseband video is where you are trying to correct 
it.  In a few words, the shape of the sync signal is damaged.  Badly.

Because most transmitters of that day used separate amplifiers for the 
audio, and the receivers have used the 4.5 mhz difference signal to 
recover the audio in the receiver for the last 63+ years, this "Incidental 
Carrier Phase Modulation" noise is impressed into the detected audio.  And 
I am sure that there are many here that can recall back a decade that the 
UHF stations in your area, all had a what was often called "chroma buzz" 
in the audio that was only about 50 db down.  Ear fatiguing at best.  
Market share effecting too.  And that translates directly into station 
income minus signs.

It was fixable, but at an additional cost in efficiency of about -20%, but 
consider what that 20% costs when a station using a 30kw rated 
transmitter, actually pulls around 225 kwh from the powerline for every 
hour it is on the air.  Bean counters have heart attacks over such 
figures.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suds 4.1 Beta Assertion Failure

2014-06-12 Thread 1stpoint
It turns out I was passing the parameters incorrectly to the generateReportSQL 
method.

This is what I had:
result=reportservice.generateReportSQL(rptRef, paramRpt, sessionid) 

This is what works:
result=XMLservice.generateReportSQL({'reportPath':rptRef},sessionid)

I have another issue.  When I make the call to return data apparently the 
result set is too big for suds and I get a MemoryError.

Here is my code snippet:
print 'executing SQL Query:',len(logicalSQL)

executionOptions={'async':False,'maxRowsPerPage':50,'refresh':True,'presentationInfo':False,'type':'Q1'}
XMLservice=obiclient.service['XmlViewService']
result=XMLservice.executeSQLQuery(logicalSQL,'SAWRowsetData',executionOptions,sessionid)

When I run it I get:
executing SQL Query: 5968
Traceback (most recent call last):
  File "C:\temp\obiee\obieetest.py", line 105, in 

result=XMLservice.executeSQLQuery(logicalSQL,'SAWRowsetData',executionOptions,sessionid)
  File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
  File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
  File "build\bdist.win32\egg\suds\client.py", line 643, in send
  File "build\bdist.win32\egg\suds\transport\https.py", line 64, in send
  File "build\bdist.win32\egg\suds\transport\http.py", line 79, in send
  File "C:\Python27\lib\socket.py", line 358, in read
buf.write(data)
MemoryError: out of memory
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Chris Angelico
On Fri, Jun 13, 2014 at 4:18 AM, Robert Lehmann  wrote:
> PS.  I found a 3.3.x commit (e3ab8aa) which fixed the LOAD_GLOBAL opcode to
> support other types than dict, but STORE_GLOBAL seems to use bare
> PyDict_SetItem instead of dispatching to PyObject_SetItem.
>

This looks like something for a tracker issue. I agree with Ian, seems
like a bug.

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


Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Ian Kelly
On Thu, Jun 12, 2014 at 12:18 PM, Robert Lehmann  wrote:
> Hi all,
>
> I have noticed there is a slight asymmetry in the way the interpreter
> (v3.3.5, reproduced also in v3.5.x) loads and stores globals.  While loading
> globals from a custom mapping triggers __getitem__ just fine, writing seems
> to silently ignore __setitem__.
>
> class Namespace(dict):
> def __getitem__(self, key):
> print("getitem", key)
> def __setitem__(self, key, value):
> print("setitem", key, value)
>
> def fun():
> global x, y
> x  # should call globals.__getitem__
> y = 1  # should call globals.__setitem__
>
> exec(fun.__code__, Namespace())
> # => getitem x
>
> I would have expected "setitem y 1" to show up as well, but to no avail.  Am
> I doing something wrong?  Is this on purpose?

Seems like a bug to me.  I note that the STORE_NAME opcode does call
__setitem__:

>>> code = compile('x = 1', '', 'exec')
>>> dis.dis(code)
  1   0 LOAD_CONST   0 (1)
  3 STORE_NAME   0 (x)
  6 LOAD_CONST   1 (None)
  9 RETURN_VALUE
>>> exec(code, Namespace())
setitem x 1

But STORE_GLOBAL does not:

>>> code = compile('global x; x = 1', '', 'exec')
>>> dis.dis(code)
  1   0 LOAD_CONST   0 (1)
  3 STORE_GLOBAL 0 (x)
  6 LOAD_CONST   1 (None)
  9 RETURN_VALUE
>>> exec(code, Namespace())
-- 
https://mail.python.org/mailman/listinfo/python-list


Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Robert Lehmann
Hi all,

I have noticed there is a slight asymmetry in the way the interpreter
(v3.3.5, reproduced also in v3.5.x) loads and stores globals.  While
loading globals from a custom mapping triggers __getitem__ just fine,
writing seems to silently ignore __setitem__.

class Namespace(dict):
def __getitem__(self, key):
print("getitem", key)
def __setitem__(self, key, value):
print("setitem", key, value)

def fun():
global x, y
x  # should call globals.__getitem__
y = 1  # should call globals.__setitem__

exec(fun.__code__, Namespace())
# => getitem x

I would have expected "setitem y 1" to show up as well, but to no avail.
 Am I doing something wrong?  Is this on purpose?

Cheers,
Robert

PS.  I found a 3.3.x commit (e3ab8aa
) which fixed the
LOAD_GLOBAL opcode to support other types than dict, but STORE_GLOBAL seems
to use bare PyDict_SetItem instead of dispatching to PyObject_SetItem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Terry Reedy

On 6/12/2014 7:38 AM, Gregory Ewing wrote:

Pedro Izecksohn wrote:

The Canvas' method create_line turns on at least 2 pixels. But I want
to turn
on many single pixels on a Canvas.


You could try using a 1x1 rectangle instead.

However, be aware that either of these will use quite a
lot of memory per pixel. If you are drawing a very large
number of pixels, this could cause performance problems.


Pedro, the tkinter canvas is a vector graphics canvas, not a bitmap 
image canvas as in paint programs.



In that case, you might want to use a different approach,
such as creating an image and telling the canvas to display
the image.


--
Terry Jan Reedy

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


كأس العالم FIFA 2014

2014-06-12 Thread essd
كأس العالم FIFA 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كأس العالم: البرازيل تستعد لاطلاق بطولة 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

مباريات كأس العالم البرازيل 2014 FIFA - FIFA.com
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

صور كأس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كأس العالم لكرة القدم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

إليكَ ترددات القنوات المفتوحة لمشاهدة المونديال مجاناً
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كيف سيشاهد العرب كأس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

جدول كاس العالم - جدول مباريات كاس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

متابعة ومشاهدة مباريات كأس العالم 2014 للأندرويد مجاناً
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

جدول مباريات كأس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

تقارير خاصة - BBC Arabic - كأس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كأس العالم 2014: تحضيرات المنتخبات الإفريقية
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

عمليات بحث متعلقة بـ كأس العالم 2014

تصفيات كأس العالم 2014 اسيا

جدول مباريات العراق في تصفيات كأس العالم 2014

كأس العالم 2022

تصفيات كأس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كأس العالم: البرازيل تستعد لاطلاق بطولة 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

القنوات الناقلة لكاس العالم 2014
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

كأس العالم 2014 : رابط مجاني لمشاهدة مباراة البرازيل وكرواتيا
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA-%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA-%D9%88%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A7%D8%AA/299719160065550

أخبار كأس العالم 2014 م بالبرازيل
https://www.facebook.com/pages/%D9%86%D8%AA%D8%A7%D8%A6%D8%AC-%D8%A7%D9%84%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%

Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris

On 6/12/14 11:57 AM, Chris Angelico wrote:

def poplist(L):

 done = False
 while done==False:

 yield L[::-1][:1:]
 L = L[::-1][1::][::-1]
 if len(L)==0: done=True


Why not just "while L"?


OK,  here it is with Chris' excellent advice:

>>> def poplist(L):
while L:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]


>>> L=[1, 2, 3, 4, 5, 6, 7]
>>> m=[]
>>> pop = poplist(L)
>>> for n in poplist(L):
m.append(n[0])


>>> m
[7, 6, 5, 4, 3, 2, 1]
>>>


==  ah  ===


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


Re: OT: This Swift thing

2014-06-12 Thread Chris Angelico
On Fri, Jun 13, 2014 at 3:04 AM, Steven D'Aprano
 wrote:
> Chris made the argument that *the laws of physics* put limits on what we
> can attain, which is fair enough, but then made the poor example of speed
> limits on roads falling short of the speed of light. Yes, speed limits on
> roads fall considerably short of the speed of light, but not because of
> laws of physics. The speed limit in my street is 50 kilometres per hour,
> not because that limit is a law of physics, or because cars are incapable
> of exceeding 50kph, but because the government where I live has decided
> that 50kph is the maximum safe speed for a car to travel in my street,
> rounded to the nearest multiple of 10kph.
>
> In other words, Chris' example is a poor one to relate to the energy
> efficiency of computing.

The point isn't so much the legal or safe limit as that that's the
speed of most driving. That is to say: Around here, most cars will
travel at roughly 50 kph, which is a far cry from c. There are other
reasons than physics for choosing a speed.

> Take three numbers, speeds in this case, s1, s2 and c, with c a strict
> upper-bound. We can take:
>
> s1 < s2 < c
>
> without loss of generality. So in this case, we say that s2 is greater
> than s1:
>
> s2 > s1
>
> Adding the constant c to both sides does not change the inequality:
>
> c + s2 > c + s1

As long as we accept that this is purely in a mathematical sense.
Let's not get into the realm of actual speeds greater than c.

> Subtracting s1 + s2 from each side:
>
> c + s2 - (s1 + s2) > c + s1 - (s1 + s2)
> c - s1 > c - s2
>
> In other words, if 250mph is larger than 150mph (a fact, as you accept),
> then it is equally a fact that 250mph is closer to the speed of light
> than 150mph. You cannot possibly have one and not the other. So why do
> you believe that the first form is acceptable, but the second form is
> nonsense?

And at this point the calculation becomes safe again, and obvious
common sense. (Or alternatively, substitute Mach 1 for c; it's not a
hard limit, but there are good reasons for staying below it in
practical application - most airliners cruise a smidge below the speed
of sound for efficiency.)

> If I were arguing that there are no engineering limits prohibiting CPUs
> reaching Landauer's limit, then you could criticise me for that, but I'm
> not making that argument.
>
> I'm saying that, whatever the practical engineering limits turn out to
> be, we're unlikely to be close to them, and therefore there are very
> likely to be many and massive efficiency gains to be made in computing.

And this I totally agree with. The limits of physics are so incredibly
far from where we now are that we can utterly ignore them; the limits
we face are generally engineering (with the exception of stuff
designed for humans to use, eg minimum useful key size is defined by
fingers and not by what we can build).

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


Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris

On 6/12/14 11:57 AM, Chris Angelico wrote:

On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris  wrote:

Consider this generator variation:


def poplist(L):

 done = False
 while done==False:

 yield L[::-1][:1:]
 L = L[::-1][1::][::-1]
 if len(L)==0: done=True


Why not just "while L"? Or are you deliberately trying to ensure that
cheating will be detectable?


;-)




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


Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris

On 6/12/14 11:55 AM, Marko Rauhamaa wrote:

while not done:

Better Python and not bad English, either.


... and taking Marko's good advice, what I think you really wanted:


>>> def poplist(L):
done = False
while not done:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
if len(L)==0: done=True


>>> L=[1, 2, 3, 4, 5, 6, 7]

>>> m=[]

>>> pop = poplist(L)

>>> for n in poplist(L):
m.append(n[0])

>>> m
[7, 6, 5, 4, 3, 2, 1]
>>>

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


Re: About python while statement and pop()

2014-06-12 Thread Marko Rauhamaa

>   while done==False:

Correction:

   while not done:

Better Python and not bad English, either.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Thu, 12 Jun 2014 05:54:47 -0700, Rustom Mody wrote:

> On Thursday, June 12, 2014 2:36:50 PM UTC+5:30, Steven D'Aprano wrote:
[...]
>> > The laws of physics tend to put
>> > boundaries that are ridiculously far from where we actually work - I
>> > think most roads have speed limits that run a fairly long way short
>> > of c.
> 
>> "186,000 miles per second: not just a good idea, it's the law"
> 
>> There's no *law of physics* that says cars can only travel at the
>> speeds they do. Compare how fast a typical racing car goes with the
>> typical 60kph speed limit in suburban Melbourne. Now compare how fast
>> the Hennessey Venom GT goes to that speed limit.
> 
>> http://www.autosaur.com/fastest-car-in-the-world/?PageSpeed=noscript
> 
> Now you (or I) are getting completely confused.
> 
> If you are saying that the Hennessey Venom (HV) is better than some
> standard vanilla Ford/Toyota (FT) based on the above, thats ok.

I'm not making any value judgements ("better" or "worse") about cars 
based on their speed. I'm just pointing out that the speed limits on our 
roads have very little to do with the speeds cars are capable of 
reaching, and *nothing* to do with ultimate limits due to the laws of 
physics.

Chris made the argument that *the laws of physics* put limits on what we 
can attain, which is fair enough, but then made the poor example of speed 
limits on roads falling short of the speed of light. Yes, speed limits on 
roads fall considerably short of the speed of light, but not because of 
laws of physics. The speed limit in my street is 50 kilometres per hour, 
not because that limit is a law of physics, or because cars are incapable 
of exceeding 50kph, but because the government where I live has decided 
that 50kph is the maximum safe speed for a car to travel in my street, 
rounded to the nearest multiple of 10kph.

In other words, Chris' example is a poor one to relate to the energy 
efficiency of computing.

A more directly relevant example would have been the efficiency of heat 
engines, where there is a fundamental physical limit of 100% efficiency. 
Perhaps Chris didn't mention that one because our technology can build 
heat engines with 60% efficiency, which is probably coming close to the 
practical upper limit of attainable efficiency -- we might, by virtue of 
clever engineering and exotic materials, reach 70% or 80% efficiency, but 
probably not 99.9% efficiency. That's a good example.

Bringing it back to computing technology, the analogy is that our current 
computing technology is like a heat engine with an efficiency of 
0.01%. Even an efficiency of 1% would be a marvelous improvement. In 
this analogy, there's an ultimate limit of 100% imposed by physics 
(Landauer's Law), and a practical limit of (let's say) 80%, but current 
computing technology is so far from those limits that those limits might 
as well not exist.


> In equations:
> maxspeed(HV) = 250 mph
> maxspeed(FT) = 150 mph
> so HV is better than FT.

"Better" is your word, not mine.

I don't actually care about fast cars, but if I did, and if I valued 
speed above everything else (cost, safety, fuel efficiency, noise, 
environmental impact, comfort, etc) then yes, I would say 250 mph is 
"better" than 150 mph, because 250 mph is larger.


> Ok...
> 
> But from your earlier statements you seem to be saying its better
> because:
> 250 mph is closer to 186,000 mps (= 670 million mph) than 150 mph
>
> Factually this is a correct statement.

And yet you're going to disagree with it, even though you agree it is 
correct?


> Pragmatically this is as nonsensical as comparing a mile and a kilogram.

This makes no sense at all.

Your two statements about speeds are logically and mathematically 
equivalent. You cannot have one without the other.

Take three numbers, speeds in this case, s1, s2 and c, with c a strict 
upper-bound. We can take:

s1 < s2 < c

without loss of generality. So in this case, we say that s2 is greater 
than s1:

s2 > s1

Adding the constant c to both sides does not change the inequality:

c + s2 > c + s1

Subtracting s1 + s2 from each side:

c + s2 - (s1 + s2) > c + s1 - (s1 + s2)
c - s1 > c - s2

In other words, if 250mph is larger than 150mph (a fact, as you accept), 
then it is equally a fact that 250mph is closer to the speed of light 
than 150mph. You cannot possibly have one and not the other. So why do 
you believe that the first form is acceptable, but the second form is 
nonsense?


>> Speed limits for human-piloted ground-based transport ("cars") are more
>> based on social and biological factors than engineering ones.
>> Similarly, there are biological factors that force keyboards to be a
>> minimum size. We probably could build a keyboard where the keys were
>> 0.1mm square, but what would be the point? Who could use it? Those
>> social and biological factors don't apply to computing efficiency, so
>> it's only *engineering* factors that prevent us from being able to run
>> your server o

Re: Python MSI Repo

2014-06-12 Thread Zachary Ware
On Thu, Jun 12, 2014 at 8:47 AM, Alex Rodrigues  wrote:
> Is there a public repository for the python windows installer?
>
> I'd like to play around with it.

The installer is built using msi.py, found in the tools directory of
the main cpython repository:
http://hg.python.org/cpython/file/default/Tools/msi/msi.py

You can also find in that directory a README.txt file which should
help you get started, and you can also refer to the 'buildmsi.bat'
script in .../Tools/buildbot/ (which is currently unused and long out
of date, but can give you an idea of what's involved).  Note that the
script has not been updated for 3.5 yet (since there hasn't been a
release yet).  Also, it is not often used by anyone other than Martin
v. Löwis who has built all of the Python Windows installers in recent
history, so it may take a bit of effort to make it work.  I have tried
and failed a couple of times, but on each occasion have run out of
time to work on it before other things called me away.

That script is liable to change in the not-too-far-distant future, as
Steve Dower is taking over installer building responsibilities from
Martin and may change the way they are built entirely.

Good luck, and have fun 'playing around'! :)

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About python while statement and pop()

2014-06-12 Thread Chris Angelico
On Fri, Jun 13, 2014 at 2:49 AM, Mark H Harris  wrote:
> Consider this generator variation:
>
 def poplist(L):
> done = False
> while done==False:
>
> yield L[::-1][:1:]
> L = L[::-1][1::][::-1]
> if len(L)==0: done=True

Why not just "while L"? Or are you deliberately trying to ensure that
cheating will be detectable?

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


Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris

On 6/11/14 10:12 PM, hito koto wrote:


def foo(x):
 y = []
 while x !=[]:
 y.append(x.pop())
 return y



Consider this generator variation:

>>> def poplist(L):
done = False
while done==False:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
if len(L)==0: done=True


>>> L1=[1, 2, 3, 4, 5, 6, 7]

>>> for n in poplist(L1):
print(n)

[7]
[6]
[5]
[4]
[3]
[2]
[1]
>>>

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


Re: About python while statement and pop()

2014-06-12 Thread Mark H Harris

On 6/11/14 10:12 PM, hito koto wrote:

i want to change this is code:

def foo(x):
 y = []
 while x !=[]:
 y.append(x.pop())
 return y



Consider this generator (all kinds of permutations on the idea):

>>> L1
[1, 2, 3, 4, 5, 6, 7]

>>> def poplist(L):
while True:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]


>>> pop = poplist(L1)

>>> next(pop)
[7]
>>> next(pop)
[6]
>>> next(pop)
[5]
>>> next(pop)
[4]
>>> next(pop)
[3]
>>> next(pop)
[2]
>>> next(pop)
[1]
>>> next(pop)
[]
>>> next(pop)
[]


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


Re: Python MSI Repo

2014-06-12 Thread Ned Batchelder

On 6/12/14 9:47 AM, Alex Rodrigues wrote:

Is there a public repository for the python windows installer?

I'd like to play around with it.

- Alex



I'm no expert on what the source for a windows installer looks like, but 
there seem to be things that smell like that in the PC and PCbuild 
directories of the CPython repository: 
http://hg.python.org/cpython/file/9aba5d75ce94


--
Ned Batchelder, http://nedbatchelder.com

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


Python MSI Repo

2014-06-12 Thread Alex Rodrigues
Is there a public repository for the python windows installer?

I'd like to play around with it.

- Alex
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Rustom Mody
I am bewildered by this argument...

[Heck Ive recently learnt that using ellipses is an easy way to 
produce literature... So there...]

On Thursday, June 12, 2014 2:36:50 PM UTC+5:30, Steven D'Aprano wrote:

> It is my contention that, had Intel and AMD spent the last few decades 
> optimizing for power consumption rather than speed, we probably could run 
> a server off, well, perhaps not a watch battery, but surely a factor of 
> 100 improvement in efficiency isn't unreasonable given that we're just 
> moving a picogram of electrons around?

This is fine and right.
I personally would pay more if my PCs/laptops etc were quieter/efficient-er.
So we agree... upto here!


> On Thu, 12 Jun 2014 12:16:08 +1000, Chris Angelico wrote:

> > On Thu, Jun 12, 2014 at 12:08 PM, Steven D'Aprano wrote:
> >> I'm just pointing out that our computational technology uses over a
> >> million times more energy than the theoretical minimum, and therefore
> >> there is a lot of room for efficiency gains without sacrificing
> >> computer power. I never imagined that such viewpoint would turn out to
> >> be so controversial.
> > The way I understand it, you're citing an extremely theoretical minimum,
> > in the same way that one can point out that we're a long way from
> > maximum entropy in a flash memory chip, so it ought to be possible to
> > pack a lot more data onto a USB stick. 

> Um, yes? 

> Hands up anyone who thinks that today's generation of USB sticks will be 
> the highest capacity ever, that all progress in packing more memory into 
> a thumb drive (or the same memory into a smaller drive) will cease 
> effective immediately?

> Anyone?

> > The laws of physics tend to put
> > boundaries that are ridiculously far from where we actually work - I
> > think most roads have speed limits that run a fairly long way short of
> > c.

> "186,000 miles per second: not just a good idea, it's the law"

> There's no *law of physics* that says cars can only travel at the speeds 
> they do. Compare how fast a typical racing car goes with the typical 
> 60kph speed limit in suburban Melbourne. Now compare how fast the 
> Hennessey Venom GT goes to that speed limit.

> http://www.autosaur.com/fastest-car-in-the-world/?PageSpeed=noscript

Now you (or I) are getting completely confused.

If you are saying that the Hennessey Venom (HV) is better than some
standard vanilla Ford/Toyota (FT) based on the above, thats ok.

In equations:
maxspeed(HV) = 250 mph
maxspeed(FT) = 150 mph
so HV is better than FT.

Ok...

But from your earlier statements you seem to be saying its better
because:
250 mph is closer to 186,000 mps (= 670 million mph) than 150 mph

Factually this is a correct statement.

Pragmatically this is as nonsensical as comparing a mile and a
kilogram.


> Speed limits for human-piloted ground-based transport ("cars") are more 
> based on social and biological factors than engineering ones. Similarly, 
> there are biological factors that force keyboards to be a minimum size. 
> We probably could build a keyboard where the keys were 0.1mm square, but 
> what would be the point? Who could use it? Those social and biological 
> factors don't apply to computing efficiency, so it's only *engineering* 
> factors that prevent us from being able to run your server off a watch 
> battery, not the laws of physics.

As best as I can see you are confused about the difference between
science and engineering.

Saying one car is better engineered than another on direct comparison
(150mph<250mph) is ok

Saying one car is better than another because of relation to physics
limits (c-150>c-250) is confusing science and engineering.

Likewise saying AMD and Intel should have done more due diligence to
their clients (and the planet) by considerging energy efficiency is right 
and I (strongly) agree.

But compare their products' realized efficiency with theoretical limits like
Landauers is a type-wrong statement
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Gregory Ewing

Pedro Izecksohn wrote:

The Canvas' method create_line turns on at least 2 pixels. But I want to turn
on many single pixels on a Canvas.


You could try using a 1x1 rectangle instead.

However, be aware that either of these will use quite a
lot of memory per pixel. If you are drawing a very large
number of pixels, this could cause performance problems.
In that case, you might want to use a different approach,
such as creating an image and telling the canvas to display
the image.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Gregory Ewing

Steven D'Aprano wrote:
It is my contention that, had Intel and AMD spent the last few decades 
optimizing for power consumption rather than speed, we probably could run 
a server off, well, perhaps not a watch battery,


Current draw of CMOS circuitry is pretty much zero when
nothing is changing, so if you didn't care how slow it ran,
you probably could run a server off a watch battery today.
Users wouldn't like waiting a week for their web pages to
load, though...

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano:
> On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote:
> 
> 
> 
> > I want to use while statement,
> 
> > 
> 
> > for example:
> 
>  def foo(x):
> 
> > ... y = []
> 
> > ... while x !=[]:
> 
> > ... y.append(x.pop())
> 
> > ... return y
> 
> > ...
> 
>  print foo(a)
> 
> > [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
> 
>  a
> 
> > []   but this is empty
> 
>  so,I want to leave a number of previous (a = [[1, 2, 3, 4],[5, 6, 7,
> 
>  8, 9],[10]])
> 
> 
> 
> 
> 
> I wouldn't use a while statement. The easy way is:
> 
> 
> 
> py> a = [[1, 2, 3, 4],[5, 6, 7, 8, 9],[10]]
> 
> py> y = a[::-1]
> 
> py> print y
> 
> [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
> 
> py> print a
> 
> [[1, 2, 3, 4], [5, 6, 7, 8, 9], [10]]
> 
> 
> 
> If you MUST use a while loop, then you need something like this:
> 
> 
> 
> 
> 
> def foo(x):
> 
> y = []
> 
> index = 0
> 
> while index < len(x):
> 
> y.append(x[i])
> 
> i += 1
> 
> return y
> 
> 
> 
> 
> 
> This does not copy in reverse order. To make it copy in reverse order, 
> 
> index should start at len(x) - 1 and end at 0.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Hi,
Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread alister
On Thu, 12 Jun 2014 09:06:50 +, Steven D'Aprano wrote:

> On Thu, 12 Jun 2014 12:16:08 +1000, Chris Angelico wrote:
> 
>> On Thu, Jun 12, 2014 at 12:08 PM, Steven D'Aprano
>>  wrote:
>>> I'm just pointing out that our computational technology uses over a
>>> million times more energy than the theoretical minimum, and therefore
>>> there is a lot of room for efficiency gains without sacrificing
>>> computer power. I never imagined that such viewpoint would turn out to
>>> be so controversial.
>> 
>> The way I understand it, you're citing an extremely theoretical
>> minimum,
>> in the same way that one can point out that we're a long way from
>> maximum entropy in a flash memory chip, so it ought to be possible to
>> pack a lot more data onto a USB stick.
> 
> Um, yes?
> 
> Hands up anyone who thinks that today's generation of USB sticks will be
> the highest capacity ever, that all progress in packing more memory into
> a thumb drive (or the same memory into a smaller drive) will cease
> effective immediately?
> 
> Anyone?
> 
> 
>> The laws of physics tend to put boundaries that are ridiculously far
>> from where we actually work - I think most roads have speed limits that
>> run a fairly long way short of c.
> 
> "186,000 miles per second: not just a good idea, it's the law"
> 
> 
> There's no *law of physics* that says cars can only travel at the speeds
> they do. Compare how fast a typical racing car goes with the typical
> 60kph speed limit in suburban Melbourne. Now compare how fast the
> Hennessey Venom GT goes to that speed limit.
> 
> http://www.autosaur.com/fastest-car-in-the-world/?PageSpeed=noscript
> 
> 
> Speed limits for human-piloted ground-based transport ("cars") are more
> based on social and biological factors than engineering ones. Similarly,
> there are biological factors that force keyboards to be a minimum size.
> We probably could build a keyboard where the keys were 0.1mm square, but
> what would be the point? Who could use it? Those social and biological
> factors don't apply to computing efficiency, so it's only *engineering*
> factors that prevent us from being able to run your server off a watch
> battery, not the laws of physics.
> 
> It is my contention that, had Intel and AMD spent the last few decades
> optimizing for power consumption rather than speed, we probably could
> run a server off, well, perhaps not a watch battery, but surely a factor
> of 100 improvement in efficiency isn't unreasonable given that we're
> just moving a picogram of electrons around?

but a 20 year old server would probably take a week to do what a current 
one does in an hour (random figures chosen for effect not accuracy).

How does the power consumption compare on those time-scales, not to 
mention the cost of the wasted time?

I would agree that for the average desk-top users modern processor 
performance exceeds that required by a considerable margin so perhaps 
optimising for power consumption is now possible, wait a minute arn't 
intel & AMD now developing lower powered processors?



-- 
Breeding rabbits is a hare raising experience.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Thu, 12 Jun 2014 12:16:08 +1000, Chris Angelico wrote:

> On Thu, Jun 12, 2014 at 12:08 PM, Steven D'Aprano
>  wrote:
>> I'm just pointing out that our computational technology uses over a
>> million times more energy than the theoretical minimum, and therefore
>> there is a lot of room for efficiency gains without sacrificing
>> computer power. I never imagined that such viewpoint would turn out to
>> be so controversial.
> 
> The way I understand it, you're citing an extremely theoretical minimum,
> in the same way that one can point out that we're a long way from
> maximum entropy in a flash memory chip, so it ought to be possible to
> pack a lot more data onto a USB stick. 

Um, yes? 

Hands up anyone who thinks that today's generation of USB sticks will be 
the highest capacity ever, that all progress in packing more memory into 
a thumb drive (or the same memory into a smaller drive) will cease 
effective immediately?

Anyone?


> The laws of physics tend to put
> boundaries that are ridiculously far from where we actually work - I
> think most roads have speed limits that run a fairly long way short of
> c.

"186,000 miles per second: not just a good idea, it's the law"


There's no *law of physics* that says cars can only travel at the speeds 
they do. Compare how fast a typical racing car goes with the typical 
60kph speed limit in suburban Melbourne. Now compare how fast the 
Hennessey Venom GT goes to that speed limit.

http://www.autosaur.com/fastest-car-in-the-world/?PageSpeed=noscript


Speed limits for human-piloted ground-based transport ("cars") are more 
based on social and biological factors than engineering ones. Similarly, 
there are biological factors that force keyboards to be a minimum size. 
We probably could build a keyboard where the keys were 0.1mm square, but 
what would be the point? Who could use it? Those social and biological 
factors don't apply to computing efficiency, so it's only *engineering* 
factors that prevent us from being able to run your server off a watch 
battery, not the laws of physics.

It is my contention that, had Intel and AMD spent the last few decades 
optimizing for power consumption rather than speed, we probably could run 
a server off, well, perhaps not a watch battery, but surely a factor of 
100 improvement in efficiency isn't unreasonable given that we're just 
moving a picogram of electrons around?


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


Re: asyncio - how to stop loop?

2014-06-12 Thread Frank Millman

"Ian Kelly"  wrote in message 
news:CALwzidnv07Wba9WJ=nuc0_v4mvudyaxwh6bgjvw0o1hf3oo...@mail.gmail.com...
> On Wed, Jun 11, 2014 at 1:19 AM, Frank Millman  wrote:
>> First attempt - same as before
>>
>> loop = asyncio.get_event_loop()
>> threading.Thread(target=loop.run_forever).start()
>> input('Press  to stop')
>> loop.stop()
>> loop.close()
>
> Each event loop is hosted by a specific thread.  In this case you're
> getting the event loop of the main thread and then trying to run it in
> a separate thread, which is not a good idea.  You can run an event
> loop in a separate thread, but you should install a separate event
> loop for that thread if you do (and then when you interact with the
> loop, do so in a thread-safe manner -- see below).
>
>> Second attempt - move the keyboard input to a separate thread
>>
>> def stop_loop():
>> input('Press  to stop')
>> loop.stop()
>> loop.close()
>>
>> loop = asyncio.get_event_loop()
>> threading.Thread(target=stop_loop).start()
>> loop.run_forever()
>
> One issue here is that (like most event loop implementations) event
> loops are not thread-safe.  To make a call to the event loop across
> threads, you should be using the call_soon_threadsafe method, e.g.
> "loop.call_soon_threadsafe(loop.stop)".  You'll also want to make sure
> that the event loop has actually stopped before you call loop.close --
> see below.
>
>> Third attempt - get the loop to close itself (cannot use in practice, but
>> see what happens)
>>
>> def stop_loop():
>> loop.stop()
>> loop.close()
>>
>> loop = asyncio.get_event_loop()
>> loop.call_later(2, stop_loop)
>> loop.run_forever()
>
> I think what's happening here is that per the docs loop.close should
> not be called while the loop is running.  You've called loop.stop but
> you're still inside a callback, which is a bit of a gray area.  You
> probably don't need to call loop.close at all, but if you want to do
> so I suggest putting it after the run_forever call, so you can be
> certain the loop has stopped when it's called.
>
> Putting all that together, you should have something like this:
>
>def stop_loop():
>input('Press  to stop')
>loop.call_soon_threadsafe(loop.stop)
>
>loop = asyncio.get_event_loop()
>threading.Thread(target=stop_loop).start()
>loop.run_forever()
>loop.close()  # optional

Thanks very much for the very clear explanation.

Your solution works perfectly.

Much appreciated.

Frank



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


Al madinah international university opening apply for university colleges (September season)

2014-06-12 Thread Marwa Kotb



MR/ MiSS

*   al madinah international university which win dependence Malaysian 
Ministry of Higher Education Malaysia (MOHE) and also winning the adoption of 
all academic programs and courses, the university that are approved by the 
Malaysian funds and private academy, which deals with quality control and 
efficiency Academy, known for short as [MQA ] to congratulate you on the 
occasion of the new academic September year  - 2014 . Its pleasure to tell you 
that the university opening  apply for university colleges.

The flowing colleges  :

* faculty of Islamic Sciences
* faculty of languages
*faculty of computer Science .
*faculty of education .
* Faculty of Science, Finance and Administration .
*Language center 
*.faculty of engineering ( soon)

The university offer :
*   Bachelor degree
*   Master  degree
*   PH degree
Both online and on campus  learning  for more information you can visit 
http://www.mediu.edu.my/ar/admissions/requirments

for more information about Bachelor degree 
http://www.mediu.edu.my/ar/admissions/undergraduateprograms

for more information about master degree 
http://www.mediu.edu.my/ar/admissions/postgraduateprograms


Best Regard international city university 
//www.mediu.edu.my/ar/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About python while statement and pop()

2014-06-12 Thread hito koto
2014年6月12日木曜日 14時43分42秒 UTC+9 Steven D'Aprano:
> On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote:
> 
> 
> 
> > I want to use while statement,
> 
> > 
> 
> > for example:
> 
>  def foo(x):
> 
> > ... y = []
> 
> > ... while x !=[]:
> 
> > ... y.append(x.pop())
> 
> > ... return y
> 
> > ...
> 
>  print foo(a)
> 
> > [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
> 
>  a
> 
> > []   but this is empty
> 
>  so,I want to leave a number of previous (a = [[1, 2, 3, 4],[5, 6, 7,
> 
>  8, 9],[10]])
> 
> 
> 
> 
> 
> I wouldn't use a while statement. The easy way is:
> 
> 
> 
> py> a = [[1, 2, 3, 4],[5, 6, 7, 8, 9],[10]]
> 
> py> y = a[::-1]
> 
> py> print y
> 
> [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
> 
> py> print a
> 
> [[1, 2, 3, 4], [5, 6, 7, 8, 9], [10]]
> 
> 
> 
> If you MUST use a while loop, then you need something like this:
> 
> 
> 
> 
> 
> def foo(x):
> 
> y = []
> 
> index = 0
> 
> while index < len(x):
> 
> y.append(x[i])
> 
> i += 1
> 
> return y
> 
> 
> 
> 
> 
> This does not copy in reverse order. To make it copy in reverse order, 
> 
> index should start at len(x) - 1 and end at 0.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Hi, Steven:
Thanks,

My goal is to be able to in many ways python

Sorry, I was mistake,
I want to leave a number of previous (a = [[10], [9, 8, 7, 6, 5], [4, 3, 2, 1]] 
)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lines on a tkinter.Canvas

2014-06-12 Thread Peter Otten
Pedro Izecksohn wrote:

> The code available from:
> http://izecksohn.com/pedro/python/canvas/testing.py
> draws 2 horizontal lines on a Canvas. Why the 2 lines differ on thickness
> and length?
> 
> The Canvas' method create_line turns on at least 2 pixels. But I want to
> turn on many single pixels on a Canvas. How should I do this? Canvas has
> no method create_pixel or create_point.

> #!/usr/bin/python3
> 
> import tkinter as tk
> 
> class Point ():
>   def __init__ (self, x, y):
> self.x = x
> self.y = y
> 
> class Board (tk.Frame):
>   def __init__ (self, bg, dimensions):
> tk.Frame.__init__ (self, tk.Tk())
> self.pack()
> self.canvas = tk.Canvas (self, bd = 0, bg = bg, width = dimensions.x, 
height = dimensions.y)
> self.canvas.pack (side = "top")
>   def drawLine (self, pa, pb, color):
> self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill = color)
>   def drawPoint (self, p, color):
> self.canvas.create_line (p.x, p.y, p.x, p.y, fill = color)
> 
> dimensions = Point (500, 500)
> board = Board ('black', dimensions)
> color = 'red'
> p = Point (0, 250)
> while (p.x < dimensions.x):
>   board.drawPoint (p, color)
>   p.x += 1
> pa = Point (0, 350)
> pb = Point (499, 350)
> board.drawLine (pa, pb, color)
> board.mainloop()

I just tried your script, and over here the line drawn with

>   def drawLine (self, pa, pb, color):
> self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill = color)

has a width of 1 pixel and does not include the end point. Therefore the 
"line" drawn with

>   def drawPoint (self, p, color):
> self.canvas.create_line (p.x, p.y, p.x, p.y, fill = color)

does not show up at all. You could try to specify the line width explicitly:

   def drawPoint (self, p, color):
 self.canvas.create_line (p.x, p.y, p.x+1, p.y, fill=color, width=1)

If that doesn't work (or there's too much overhead) use pillow to prepare an 
image and show that.

Another random idea: if you have a high resolution display your OS might 
blow up everything. In that case there would be no fix on the application 
level.

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