Re: executor.map() TypeError: zip argument #2 must support iteration

2013-04-01 Thread Steven D'Aprano
On Sun, 31 Mar 2013 21:45:21 -0700, iMath wrote:

> executor.map()TypeError: zip argument #2 must support iteration
> 
> when I run it ,just generated TypeError: zip argument #2 must support
> iteration. can anyone help me fix this problem ?

Yes. Read the error message, and inspect the line that is in error. You 
have:

> future_to_url = executor.map(str,lst100, 60)

executor.map has three arguments:

Arg 0: str
Arg 1: list of 100 ints
Arg 2: int 60

Argument 2, the number 60, does not support iteration, since it is an int.

Now read the docs for map. At the interactive interpreter, do this:

py> from concurrent.futures import ThreadPoolExecutor
py> help(ThreadPoolExecutor.map)


and you will see the following documentation:

map(self, fn, *iterables, timeout=None)
Returns a iterator equivalent to map(fn, iter).

Args:
fn: A callable that will take take as many arguments as there are
passed iterables.
timeout: The maximum number of seconds to wait. If None, then
there is no limit on the wait time.


Notice that the iterables argument is prefixed with * symbol. That means 
that it collects all the remaining positional arguments, which means that 
the timeout argument is keyword only.

So try this:


future_to_url = executor.map(str, lst100, timeout=60)


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


Is there a simple stand alone python app I can use on my Kindle fire?

2013-04-01 Thread ah



(it was recommended that I post this query here (originally posted on the tutor 
page)).
 

Hello,


I'm enjoying learning python, and would like to be able to study and practice 
on the go, using my kindle fire reader. (wifi enabled).


Amazon does have an app, Qpython lite, but requires a  live wifi connection to 
the internet to run. I'm looking for a simple python app, stand alone that i 
can run on my kindle, without an internet connection,  just to practice while i 
learn. (Just a simple terminal, and text editor, and python? like ubuntu 
offers.)


I've tried downloading portable python, and couldnt' get it to run ('can't run 
in DOS mode?'), I've tried downloading ubuntu to my kindle and couldn't, and 
tried downloading the whole 2.7 python app, but couldn't get it to run.

I tried to root my kindle, but as I'm inexperienced in things tech, i'm not 
sure if I was successful, and not sure how this helps (if I was successful.)


I have both windows 7 and ubuntu (dual boot) on my laptop, and can connect my 
kindle to the laptop via usb cable. I have "accept downloads from other 
applications" enabled on my kindle. On my kindle I have 'better terminal 
emulator pro' , ES file explorer, and droidedit.


Any help is appreciated, I'm willing to follow step by step instructions to get 
python running on my kindle. I will supply any other details required.


My kindle fire specs are : Model D01400



The Kindle Fire features a 7” display module from LG Display. The 
display is dual-sourced between LG Display and E Ink Holdings. The 
display touchscreen appears to be conventional capacitive glass on glass and 
the control IC on the touchscreen is from a previously unseen 
source. Meanwhile, the OMAP4430 applications processor from Texas 
Instruments is a dual-core RM Cortex-A9, 1GHz processor with IVA 3 
Hardware Accelerator, SGX540 3D Graphic Core, 1080P 2D, 720P 3D and is 
produced in 45nm process geometry. 

Other key features include a
 8GB eMMC NAND Flash Memory, 4Gbits of low power DDR2, a 3.7V battery 
with 4400mAh capacity (or about 16 Wh), and a module from Jorjin, which 
is based on Texas Instruments’ WL1270. -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread Steven D'Aprano
On Sun, 31 Mar 2013 22:33:45 -0700, rusi wrote:

> On Mar 31, 5:55 pm, Mark Lawrence  wrote:
> 
> 
> 
>> I'm feeling very sorry for this horse, it's been flogged so often it's
>> down to bare bones.
> 
> While I am now joining the camp of those fed up with jmf's whining, I do
> wonder if we are shooting the messenger…

No. The trouble is that the messenger is shouting that the Unicode world 
is ending on December 21st 2012, and hasn't noticed that was over three 
months ago and the world didn't end.

 
[...]
>> OK, that leads to the next question.  Is there anyway I can (in Python
>> 2.7) detect when a string is not entirely in the BMP?  If I could find
>> all the non-BMP characters, I could replace them with U+FFFD
>> (REPLACEMENT CHARACTER) and life would be good (enough).

Of course you can do this, but you should not. If your input data 
includes character C, you should deal with character C and not just throw 
it away unnecessarily. That would be rude, and in Python 3.3 it should be 
unnecessary.

Although, since the person you are quoting is stuck in Python 2.7, it may 
be less bad than having to deal with potentially broken Unicode strings.


> Steven's:
>> But it means that if you're one of the 99.9% of users who mostly use
>> characters in the BMP, …

Yes. "Mostly" does not mean exclusively, and given (say) a billion 
computer users, that leaves about a million users who have significant 
need for non-BMP characters.

If you don't agree with my estimate, feel free to invent your own :-)


> And from http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html
>> The informal name for the supplementary planes of Unicode is "astral
>> planes", since (especially in the late '90s) their use seemed to be as
>> remote as the theosophical "great beyond". …

That was nearly two decades ago. Two decades ago, the idea that the 
entire computing world could standardize on a single character set, 
instead of having to deal with dozens of different "code pages", seemed 
as likely as people landing on the Moon seemed in 1940.

Today, the entire computing world has standardized on such a system, 
"code pages" (encodings) are mostly only needed for legacy data and 
shitty applications, but most implementations don't support the entire 
Unicode range. A couple of programming languages, including Pike and 
Python, support Unicode fully and correctly. Pike has never had the same 
high-profile as Python, but now that Python can support the entire 
Unicode range without broken surrogate support, maybe users of other 
languages will start to demand the same.


> So I really wonder: Is python losing more by supporting SMP with
> performance hit on BMP?

No.

As many people have demonstrated, both with code snippets and whole-
program benchmarks, Python 3.3 is *as fast* or *faster* than Python 3.2 
narrow builds. In practice, Python 3.3 saves enough memory by using 
sensible string implementations that real world software is faster in 
Python 3.3 than in 3.2.


> The problem as I see it is that a choice that is sufficiently skew is no
> more a straightforward choice. An example will illustrate:
> 
> I can choose to drive or not -- a choice. Statistics tell me that on
> average there are 3 fatalities every day; I am very concerned that I
> could get killed so I choose not to drive. Which neglects that there are
> a couple of million safe-drives at the same time as the '3 fatalities'

Clear as mud. What does this have to do with supporting Unicode?




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


How to do this?

2013-04-01 Thread Ana Dionísio
So I have this script:

"
from numpy import array

vt=[0]*20
vt = array(vt, dtype=dict)

for t in range(20):
if t == 4:
vt[t]=1

else:
vt[t]=0
"

And have this output:

[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

What I need is when t == 4 I need to put 1 in that position and in the next 3, 
for example the following output:

[0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]

Do you have any suggestions?


I'm sorry if I can't explain this in a better way, English is not my first 
language

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


Re: How to do this?

2013-04-01 Thread Vincent Vande Vyvre
Le 01/04/13 12:14, Ana Dionísio a écrit :
> for t in range(20):
> if t == 4:
> vt[t]=1
Sets only the needed values:

for t in range(4, 8):
vt[t]=1



-- 
Vincent V.V.
Oqapy  . Qarte
 . PaQager 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to do this?

2013-04-01 Thread Ana Dionísio
Nice! Thank you!

And if I need something like this?

[0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]

How can I do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to do this?

2013-04-01 Thread Peter Otten
Ana Dionísio wrote:

> Nice! Thank you!
> 
> And if I need something like this?
> 
> [0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]
> 
> How can I do this?

With vanilla Python:

>>> vt = [0] * 20
>>> for i, v in enumerate(vt):
... if 4 <= i < 8 or 13 <= i < 16:
... vt[i] = .17
... 
>>> vt
[0, 0, 0, 0, 0.17, 0.17, 0.17, 0.17, 0, 0, 0, 0, 0, 0.17, 0.17, 0.17, 0, 0, 
0, 0]

With vanilla Python using slices:

>>> vt = [0] * 20
>>> vt[4:8] = [.17]*4
>>> vt[13:16] = [.17]*3
>>> vt
[0, 0, 0, 0, 0.17, 0.17, 0.17, 0.17, 0, 0, 0, 0, 0, 0.17, 0.17, 0.17, 0, 0, 
0, 0]

With numpy:

>>> vt = numpy.zeros(20)
>>> vt[4:8] = vt[13:16] = .17
>>> vt
array([ 0.  ,  0.  ,  0.  ,  0.  ,  0.17,  0.17,  0.17,  0.17,  0.  ,
0.  ,  0.  ,  0.  ,  0.  ,  0.17,  0.17,  0.17,  0.  ,  0.  ,
0.  ,  0.  ])


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


Re: Creating a dictionary from a .txt file

2013-04-01 Thread Neil Cerutti
On 2013-03-31, Roy Smith  wrote:
> And, this is a good excuse to explore some of the interesting
> third-party modules.  For example, mwclient ("pip install
> mwclient") gives you a neat Python interface to wikipedia.  And
> there's a whole landscape of string matching packages to
> explore.
>
> We deal with this every day at Songza.  Are Kesha and Ke$ha the
> same artist?  Pushing back on the record labels to clean up
> their catalogs isn't going to get us very far.

I tried searching for Frost*, an interesting artist I recently
learned about. His name, in combination with a similarly named
rap artist, breaks most search tools.

My guess is this homework is simply borken.

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


Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Roy Smith
In article <51590a2b$0$3$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> Concrete examples of transitive relations: greater than, equal to, less 
> than and equal to.

Will Python 4 implement "less than and equal to"? :-)

[Warning: topic creep]

Well, they are transitive over certain domains.  Or, perhaps, a better 
way to say it is they are transitive according to their traditional 
mathematical definitions.  But, computer languages don't always follow 
those.

I used to work with a guy who was originally a math major.  He used to 
always complain about things like:

s = "foo" + "bar"

because addition is supposed to be commutative.

But, yeah, I know what you're saying that "transitive" applies to 
relations, not to operators.

Although, of course, in some languages, relations *are* operators.  
There's that pesky math vs. programming language dichotomy again.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to do this?

2013-04-01 Thread Dave Angel

On 04/01/2013 07:08 AM, Ana Dionísio wrote:

[0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]



I'd do
res = "[0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]"

Unless there's a pattern you're trying to accomplish (like maybe next 
time you want to do "it" for a list of two million items), there's 
little point in writing code to do what you've already predetermined. 
And if there is a pattern, you'd probably better let us know.


But if it's for fun,



vt = [0] * 21
for index, val in enumerate(vt):
if 3http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread Roy Smith
In article <515941d8$0$29967$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> [...]
> >> OK, that leads to the next question.  Is there anyway I can (in Python
> >> 2.7) detect when a string is not entirely in the BMP?  If I could find
> >> all the non-BMP characters, I could replace them with U+FFFD
> >> (REPLACEMENT CHARACTER) and life would be good (enough).
> 
> Of course you can do this, but you should not. If your input data 
> includes character C, you should deal with character C and not just throw 
> it away unnecessarily. That would be rude, and in Python 3.3 it should be 
> unnecessary.

The import job isn't done yet, but so far we've processed 116 million 
records and had to clean up four of them.  I can live with that.  
Sometimes practicality trumps correctness.

It turns out, the problem is that the version of MySQL we're using 
doesn't support non-BMP characters.  Newer versions do (but you have to 
declare the column to use the utf8bm4 character set).  I could upgrade 
to a newer MySQL version, but it's just not worth it.

Actually, I did try spinning up a 5.5 instance (one of the nice things 
of being in the cloud) and experimented with that, but couldn't get it 
to work there either.  I'll admit that I didn't invest a huge amount of 
effort to make that work before just writing this:

def bmp_filter(self, s):
"""Filter a unicode string to remove all non-BMP (basic
 multilingual plane) characters.  All such characters are
 replaced with U+FFFD (Unicode REPLACEMENT CHARACTER).

 """
if all(ord(c) <= 0x for c in s):
return s
else:
self.logger.warning("making %r BMP-clean", s)
bmp_chars = [(c if ord(c) <= 0x else u'\ufffd') for c in 
s]
return ''.join(bmp_chars)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to do this?

2013-04-01 Thread Mark Lawrence

On 01/04/2013 11:14, Ana Dionísio wrote:

So I have this script:

"
from numpy import array


Are you aware that this overrides the Python builtin array?  It's 
usually but not always better to do this


import numpy as np
vt = np.array(vt, dtype=dict)



vt=[0]*20
vt = array(vt, dtype=dict)

for t in range(20):
 if t == 4:
 vt[t]=1

 else:
 vt[t]=0


Why the loop, you've already initialise the array to zeroes?


"

And have this output:

[0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

What I need is when t == 4 I need to put 1 in that position and in the next 3, 
for example the following output:

[0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]

Do you have any suggestions?


Use slicing.
vt[4:8] = 1




I'm sorry if I can't explain this in a better way, English is not my first 
language

Thank you



--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Performance of int/long in Python 3

2013-04-01 Thread rusi
On Apr 1, 5:15 pm, Roy Smith  wrote:
> In article <515941d8$0$29967$c3e8da3$54964...@news.astraweb.com>,
>  Steven D'Aprano  wrote:
>
> > [...]
> > >> OK, that leads to the next question.  Is there anyway I can (in Python
> > >> 2.7) detect when a string is not entirely in the BMP?  If I could find
> > >> all the non-BMP characters, I could replace them with U+FFFD
> > >> (REPLACEMENT CHARACTER) and life would be good (enough).
>
> > Of course you can do this, but you should not. If your input data
> > includes character C, you should deal with character C and not just throw
> > it away unnecessarily. That would be rude, and in Python 3.3 it should be
> > unnecessary.
>
> The import job isn't done yet, but so far we've processed 116 million
> records and had to clean up four of them.  I can live with that.
> Sometimes practicality trumps correctness.

That works out to 0.03%. Of course I assume it is US only data.
Still its good to know how skew the distribution is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Error in working with Dict

2013-04-01 Thread inshu chauhan
I have this program which is working with 2 dictionaries segments,
class_counts.. but I am getting an error mentioned below the programme.

import cv
from itertools import *
from math import floor, sqrt, ceil
from numpy import array, dot, subtract, add, outer, argmax, linalg as lin


def Computesegclass(segimage, refimage):
f = open("Pixel_count_with_region_num_trial1.txt", "w")
segments = {}
class_count = {}
for y in xrange(0, segimage.height):
for x in xrange(0, segimage.width):

if segimage[y,x] == (0.0, 0.0, 0.0):
continue
else:
seg_color = segimage[y,x]
blue = int(seg_color[0])
green = int(seg_color[1])
red = int(seg_color[2])
region_num = blue + 256 * green + 65536 * red
#print region_num
segments[region_num] = segments.setdefault(region_num, 0) +
1
#print segments

class_color = refimage[y,x]

if class_color == (0.0,0.0,0.0):
class_number = 0  # No class
elif class_color == (0.0,255.0,0.0):
class_number = 1   # Trees
elif class_color == (255.0, 0.0, 128.0):
class_number = 2   # Buildings
elif class_color == (0.0,0.0,255.0):
class_number = 3# Automobiles
elif class_color == (255.0, 255.0, 0.0):
class_number = 4# Road Points
elif class_color == (0.0, 64.0, 128.0):
class_number = 5# Tree trunks nad branches
elif class_color == (255.0, 0.0 ,0.0):
class_number = 6# Poles
elif class_color == (255.0, 0.0, 255.0):
class_number = 7# Traffic Lights
else:
class_number = 0 # Gray Pixel

class_count.setdefault(region_num, [0, 0, 0, 0, 0, 0, 0,
0])[class_number] += 1
# print class_count
for k in sorted(class_count.iterkeys()):
i = argmax(class_count[k])
print >> f, i

if __name__== "__main__":
segimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
Thesis\Segmentation\segmentation_numbers_0.tif",
cv.CV_LOAD_IMAGE_UNCHANGED)
refimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
Thesis\Segmentation\Hand_Classified1.tif", cv.CV_LOAD_IMAGE_UNCHANGED)
print segimage
Computesegclass(segimage, refimage)


ERROR :

Traceback (most recent call last):
  File "C:\Users\inshu\Desktop\seg.py", line 49, in 
for k in sorted(class_count.iterkeys()):
NameError: name 'class_count' is not defined

I know this error is because I have initialized both dicts inside the
function, But why dicts are not saved out, if I intialize the dicts outside
the function, the processing is still done inside and end result I am
getting is an empty dict.


Thanks in Advance for suggestions
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in working with Dict

2013-04-01 Thread Vincent Vande Vyvre
Le 01/04/13 15:50, inshu chauhan a écrit :
> I have this program which is working with 2 dictionaries segments,
> class_counts.. but I am getting an error mentioned below the programme. 
>
> import cv
> from itertools import *
> from math import floor, sqrt, ceil
> from numpy import array, dot, subtract, add, outer, argmax, linalg as lin
>
>
> def Computesegclass(segimage, refimage):  
> f = open("Pixel_count_with_region_num_trial1.txt", "w")
> segments = {}
> class_count = {}
> for y in xrange(0, segimage.height):
> for x in xrange(0, segimage.width):
>
> if segimage[y,x] == (0.0, 0.0, 0.0):
> continue
> else:
> seg_color = segimage[y,x]
> blue = int(seg_color[0])
> green = int(seg_color[1])
> red = int(seg_color[2])
> region_num = blue + 256 * green + 65536 * red
> #print region_num
> segments[region_num] = segments.setdefault(region_num,
> 0) + 1
> #print segments
> 
> class_color = refimage[y,x]
> 
> if class_color == (0.0,0.0,0.0):
> class_number = 0  # No class
> elif class_color == (0.0,255.0,0.0):
> class_number = 1   # Trees 
> elif class_color == (255.0, 0.0, 128.0):
> class_number = 2   # Buildings 
> elif class_color == (0.0,0.0,255.0):
> class_number = 3# Automobiles 
> elif class_color == (255.0, 255.0, 0.0):
> class_number = 4# Road Points 
> elif class_color == (0.0, 64.0, 128.0):
> class_number = 5# Tree trunks nad branches 
> elif class_color == (255.0, 0.0 ,0.0):
> class_number = 6# Poles  
> elif class_color == (255.0, 0.0, 255.0):
> class_number = 7# Traffic Lights
> else:
> class_number = 0 # Gray Pixel
> 
> class_count.setdefault(region_num, [0, 0, 0, 0, 0, 0,
> 0, 0])[class_number] += 1
> # print class_count
> for k in sorted(class_count.iterkeys()):
> i = argmax(class_count[k])
> print >> f, i 
>
> if __name__== "__main__":
> segimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
> Thesis\Segmentation\segmentation_numbers_0.tif",
> cv.CV_LOAD_IMAGE_UNCHANGED)
> refimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
> Thesis\Segmentation\Hand_Classified1.tif", cv.CV_LOAD_IMAGE_UNCHANGED)
> print segimage
> Computesegclass(segimage, refimage)
>
>
> ERROR : 
>
> Traceback (most recent call last):
>   File "C:\Users\inshu\Desktop\seg.py", line 49, in 
> for k in sorted(class_count.iterkeys()):
> NameError: name 'class_count' is not defined
>
> I know this error is because I have initialized both dicts inside the
> function, But why dicts are not saved out, if I intialize the dicts
> outside the function, the processing is still done inside and end
> result I am getting is an empty dict.
>
>
> Thanks in Advance for suggestions 
>
>
>
Get the class_count in the return of Computesegclass


cc =  Computesegclass(segimage, refimage)
for k in sorted(cc.iterkeys()):
...
-- 
Vincent V.V.
Oqapy  . Qarte
 . PaQager 
-- 
http://mail.python.org/mailman/listinfo/python-list


PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Pierre O'Dee
PSF [Beaverton, OR] 1 April 2013 -- At a news conference held
earlier today, Guido van Rossum announced that he is quitting
Python to develop a new language.

"Python just makes programming too damn easy and too bug-free,"
Guido said as part of his remarks in a brief, prepared statement.
He added, "The way things are going, soon, everyone in the world
will be programming in Python -- even children!"

Guido went on to say that he's now working on a new language
called Giddy-up-and-Go which will take the worst features of C++,
Java, and French combined with elements of both PHP and Klingon
syntax. He said that this new endeavor should put the work and
frustration back into programming "[where] it ought to be."
Responding to a reporter's question in a brief Q&A following the
announcement, Guido said, "Real programmers don't need no
stinkin' easy and intuitive language to program with."

Some features have already been hinted at for the new language.
No Unicode -- BAUDOT is expected to be the new character
encoding. Numeric types have been eliminated as it's no longer
relevant or possible for most students and younger PhDs to do
even simple arithmetic considering the current state of the
so-called educational system. One surprising feature is that
everything will be a subject using Guido's new subject-oriented
programming (SOP) paradigm. Other sources said that variables
(subjects in the new paradigm) will now be passed by gas.

Python 3.3 will be the last version of Python. Look for
announcements soon for the new Giddy-up-and-Go mailing lists.

PSF will be selling its holdings to Oracle as they've embraced
the open-source philosophy so freely and warmly. One insider
shared unconfirmed rumors that Mr. Johnson will be attempting to
revive and steer the now defunct Python language -- which
elicited further concerns amongst the somewhat bewildered Python
community.

All newsgroups mentioning Python -- the full Monty -- will be
closed today.

--Pierre O'Dee, self-appointed spokesman for the PSF
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 2:30 AM, Pierre O'Dee  wrote:
> One insider
> shared unconfirmed rumors that Mr. Johnson will be attempting to
> revive and steer the now defunct Python language

It's about time his untiring contributions to this list and the
language were recognized.

I fully support this move.

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


A Healthy Alternative to Takeaway Regret

2013-04-01 Thread 23alagmy
A Healthy Alternative to Takeaway Regret

http://natigtas7ab.blogspot.com/2013/03/a-healthy-alternative-to-takeaway-regret.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Grant Edwards
On 2013-04-01, Pierre O'Dee  wrote:

[...]

It took me an embarassingly long time to 'get' Mr. O'Dee's name.

-- 
Grant Edwards   grant.b.edwardsYow! I put aside my copy
  at   of "BOWLING WORLD" and
  gmail.comthink about GUN CONTROL
   legislation...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 06:11:50 -0700, rusi wrote:

> On Apr 1, 5:15 pm, Roy Smith  wrote:

>> The import job isn't done yet, but so far we've processed 116 million
>> records and had to clean up four of them.  I can live with that.
>> Sometimes practicality trumps correctness.
> 
> That works out to 0.03%. Of course I assume it is US only data.
> Still its good to know how skew the distribution is.

If the data included Japanese names, or used Emoji, it would be much 
closer to 100% than 0.03%.



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


Re: Performance of int/long in Python 3

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 08:15:53 -0400, Roy Smith wrote:

> In article <515941d8$0$29967$c3e8da3$54964...@news.astraweb.com>,
>  Steven D'Aprano  wrote:
> 
>> [...]
>> >> OK, that leads to the next question.  Is there anyway I can (in
>> >> Python 2.7) detect when a string is not entirely in the BMP?  If I
>> >> could find all the non-BMP characters, I could replace them with
>> >> U+FFFD (REPLACEMENT CHARACTER) and life would be good (enough).
>> 
>> Of course you can do this, but you should not. If your input data
>> includes character C, you should deal with character C and not just
>> throw it away unnecessarily. That would be rude, and in Python 3.3 it
>> should be unnecessary.
> 
> The import job isn't done yet, but so far we've processed 116 million
> records and had to clean up four of them.  I can live with that.
> Sometimes practicality trumps correctness.

Well, true. It has to be said that few programming languages (and 
databases) make it easy to do the right thing. On the other hand, you're 
a programmer. Your job is to write correct code, not easy code.

 
> It turns out, the problem is that the version of MySQL we're using

Well there you go. Why don't you use a real database? 

http://www.postgresql.org/docs/9.2/static/multibyte.html

:-)

Postgresql has supported non-broken UTF-8 since at least version 8.1.


> doesn't support non-BMP characters.  Newer versions do (but you have to
> declare the column to use the utf8bm4 character set).  I could upgrade
> to a newer MySQL version, but it's just not worth it.

My brain just broke. So-called "UTF-8" in MySQL only includes up to a 
maximum of three-byte characters. There has *never* been a time where 
UTF-8 excluded four-byte characters. What were the developers thinking, 
arbitrarily cutting out support for 50% of UTF-8?



> Actually, I did try spinning up a 5.5 instance (one of the nice things
> of being in the cloud) and experimented with that, but couldn't get it
> to work there either.  I'll admit that I didn't invest a huge amount of
> effort to make that work before just writing this:
> 
> def bmp_filter(self, s):
> """Filter a unicode string to remove all non-BMP (basic
>  multilingual plane) characters.  All such characters are
>  replaced with U+FFFD (Unicode REPLACEMENT CHARACTER).
> 
>  """

I expect that in 5-10 years, applications that remove or mangle non-BMP 
characters will be considered as unacceptable as applications that mangle 
BMP characters. Or for that matter, applications that cannot handle names 
with apostrophes.

Hell, if your customer base is in Asia, chances are that mangling non-BMP 
characters is *already* considered unacceptable.


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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 3:18 AM, Grant Edwards  wrote:
> On 2013-04-01, Pierre O'Dee  wrote:
>
> [...]
>
> It took me an embarassingly long time to 'get' Mr. O'Dee's name.

I only just did now, after you pointed it out. Must be an accent
thing, that's not really how I pronounce the word.

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 4:07 AM, Steven D'Aprano
 wrote:
> On Mon, 01 Apr 2013 08:15:53 -0400, Roy Smith wrote:
>> It turns out, the problem is that the version of MySQL we're using
>
> Well there you go. Why don't you use a real database?
>
> http://www.postgresql.org/docs/9.2/static/multibyte.html
>
> :-)
>
> Postgresql has supported non-broken UTF-8 since at least version 8.1.

Not only that, but I *rely* on PostgreSQL to test-or-reject stuff that
comes from untrustworthy languages, like PHP. If it's malformed in any
way, it won't get past the database.

>> doesn't support non-BMP characters.  Newer versions do (but you have to
>> declare the column to use the utf8bm4 character set).  I could upgrade
>> to a newer MySQL version, but it's just not worth it.
>
> My brain just broke. So-called "UTF-8" in MySQL only includes up to a
> maximum of three-byte characters. There has *never* been a time where
> UTF-8 excluded four-byte characters. What were the developers thinking,
> arbitrarily cutting out support for 50% of UTF-8?

Steven, you punctuated that wrongly.

What, were the developers *thinking*? Arbitrarily etc?

It really is brain-breaking. I could understand a naive UTF-8 codec
being too permissive (allowing over-long encodings, allowing
codepoints above what's allocated (eg FA 80 80 80 80, which would
notionally represent U+200), etc), but why should it arbitrarily
stop short? There must have been some internal limitation - that,
perhaps, collation was defined only within the BMP.

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Emanuel Woiski
On 2013-04-01, Pierre O'Dee  wrote:
Guido went on to say that he's now working on a new language
called Giddy-up-and-Go which will take the worst features of C++,
Java, and French combined with elements of both PHP and Klingon
syntax.
[...]
We are all eagerly waitin' for the new GuG (or GuGO?) language!
Is it on github?
regards
woiski
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in working with Dict

2013-04-01 Thread Dave Angel

On 04/01/2013 09:50 AM, inshu chauhan wrote:

I have this program which is working with 2 dictionaries segments,
class_counts.. but I am getting an error mentioned below the programme.

import cv
from itertools import *
from math import floor, sqrt, ceil
from numpy import array, dot, subtract, add, outer, argmax, linalg as lin


def Computesegclass(segimage, refimage):
 f = open("Pixel_count_with_region_num_trial1.txt", "w")
 segments = {}
 class_count = {}
 for y in xrange(0, segimage.height):
 for x in xrange(0, segimage.width):

 if segimage[y,x] == (0.0, 0.0, 0.0):
 continue
 else:
 seg_color = segimage[y,x]
 blue = int(seg_color[0])
 green = int(seg_color[1])
 red = int(seg_color[2])
 region_num = blue + 256 * green + 65536 * red
 #print region_num
 segments[region_num] = segments.setdefault(region_num, 0) +
1
 #print segments

 class_color = refimage[y,x]

 if class_color == (0.0,0.0,0.0):
 class_number = 0  # No class
 elif class_color == (0.0,255.0,0.0):
 class_number = 1   # Trees
 elif class_color == (255.0, 0.0, 128.0):
 class_number = 2   # Buildings
 elif class_color == (0.0,0.0,255.0):
 class_number = 3# Automobiles
 elif class_color == (255.0, 255.0, 0.0):
 class_number = 4# Road Points
 elif class_color == (0.0, 64.0, 128.0):
 class_number = 5# Tree trunks nad branches
 elif class_color == (255.0, 0.0 ,0.0):
 class_number = 6# Poles
 elif class_color == (255.0, 0.0, 255.0):
 class_number = 7# Traffic Lights
 else:
 class_number = 0 # Gray Pixel

 class_count.setdefault(region_num, [0, 0, 0, 0, 0, 0, 0,
0])[class_number] += 1
 # print class_count


You do realize you ended the function when you put the following line at 
the left margin?  Perhaps you really intended to put the for loop inside 
the function?  I can't tell.


You don't call Computesegclass() till later, so how can you use its 
dicts, even if it did correctly pass them back?



for k in sorted(class_count.iterkeys()):
 i = argmax(class_count[k])
 print >> f, i

if __name__== "__main__":
 segimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
Thesis\Segmentation\segmentation_numbers_0.tif",
cv.CV_LOAD_IMAGE_UNCHANGED)
 refimage = cv.LoadImageM(r"C:\Users\inshu\Desktop\Masters
Thesis\Segmentation\Hand_Classified1.tif", cv.CV_LOAD_IMAGE_UNCHANGED)
 print segimage
 Computesegclass(segimage, refimage)


ERROR :

Traceback (most recent call last):
   File "C:\Users\inshu\Desktop\seg.py", line 49, in 
 for k in sorted(class_count.iterkeys()):
NameError: name 'class_count' is not defined

I know this error is because I have initialized both dicts inside the
function, But why dicts are not saved out, if I intialize the dicts outside
the function, the processing is still done inside and end result I am
getting is an empty dict.


Thanks in Advance for suggestions






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


Re: Performance of int/long in Python 3

2013-04-01 Thread MRAB

On 01/04/2013 18:07, Steven D'Aprano wrote:

On Mon, 01 Apr 2013 08:15:53 -0400, Roy Smith wrote:


In article <515941d8$0$29967$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:


[...]
>> OK, that leads to the next question.  Is there anyway I can (in
>> Python 2.7) detect when a string is not entirely in the BMP?  If I
>> could find all the non-BMP characters, I could replace them with
>> U+FFFD (REPLACEMENT CHARACTER) and life would be good (enough).

Of course you can do this, but you should not. If your input data
includes character C, you should deal with character C and not just
throw it away unnecessarily. That would be rude, and in Python 3.3 it
should be unnecessary.


The import job isn't done yet, but so far we've processed 116 million
records and had to clean up four of them.  I can live with that.
Sometimes practicality trumps correctness.


Well, true. It has to be said that few programming languages (and
databases) make it easy to do the right thing. On the other hand, you're
a programmer. Your job is to write correct code, not easy code.



It turns out, the problem is that the version of MySQL we're using


Well there you go. Why don't you use a real database?

http://www.postgresql.org/docs/9.2/static/multibyte.html

:-)

Postgresql has supported non-broken UTF-8 since at least version 8.1.



doesn't support non-BMP characters.  Newer versions do (but you have to
declare the column to use the utf8bm4 character set).  I could upgrade
to a newer MySQL version, but it's just not worth it.


My brain just broke. So-called "UTF-8" in MySQL only includes up to a
maximum of three-byte characters. There has *never* been a time where
UTF-8 excluded four-byte characters. What were the developers thinking,
arbitrarily cutting out support for 50% of UTF-8?


[snip]
50%? The BMP is one of 17 planes, so wouldn't that be 94%?

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Mark Lawrence

On 01/04/2013 16:30, Pierre O'Dee wrote:


Some features have already been hinted at for the new language.
No Unicode -- BAUDOT is expected to be the new character
encoding.

--Pierre O'Dee, self-appointed spokesman for the PSF



This is excellent news, no unicode means no chance of any performance 
regressions whilst implementing stupid things like memory savings and 
correctness.


One question, why use a character encoding that's named after a very 
famous French actress?


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Help with python code!

2013-04-01 Thread Alister
On Sun, 31 Mar 2013 14:32:21 -0700, gerrymcgovern wrote:

> On Sunday, March 31, 2013 5:27:06 PM UTC-4, Roy Smith wrote:
>> In article <4455829d-5b4a-44ee-b65f-5f72d429b...@googlegroups.com>,
>> 
>>  jojo  wrote:
>> 
>> 
>> 
>> > Thanks for your replies. Just to be clear this is for a interview and
>> > they
>> 
>> > would like me to figure out what the code does and come back with
>> > some test
>> 
>> > cases. I don't need to code the tests, just give some high level
>> > tests. As
>> 
>> > far as I can make out it is some system where you input your name and
>> > it will
>> 
>> > bring back your details plus how much time you have left on your
>> > card. Have
>> 
>> > to say I find the code extremely confusing, hopefully all python
>> > isn't like
>> 
>> > this!!
>> 
>> 
>> 
>> If this is for an interview, you really should be doing this on your
>> 
>> own.  I assume the point of the interview is to see how well you know
>> 
>> Python.  Please don't expect people here to take your interview for
>> you.
> 
> Where did I ask people to take the interview for me? I asked for some
> tips on interpreting the code something which you have been unable to
> give me. If a senior dev (I am assuming you are a python dev) is unable
> to figure out what the code does, then I think me, been a newbie to new
> language (with horrible syntax) is entitled to ask for help.

I think Roy's point here is if you don't know python (as you admit) why 
are you applying for a job as a Python Developer.

the code provided appears to be pretty poor quality to me & probably 
buggy as well but without the specification I can't be sure.




-- 
I like work; it fascinates me; I can sit and look at it for hours.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Ethan Furman

On 04/01/2013 10:21 AM, Emanuel Woiski wrote:

On 2013-04-01, Pierre O'Dee  wrote:
Guido went on to say that he's now working on a new language
called Giddy-up-and-Go which will take the worst features of C++,
Java, and French combined with elements of both PHP and Klingon
syntax.
[...]
We are all eagerly waitin' for the new GuG (or GuGO?) language!


I think the 'U' is silent, making it GAG.

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Steve Simmons
It's in recognition of the gap between English and French - it helps you to 
bridge it.


Mark Lawrence  wrote:

>On 01/04/2013 16:30, Pierre O'Dee wrote:
>>
>> Some features have already been hinted at for the new language.
>> No Unicode -- BAUDOT is expected to be the new character
>> encoding.
>>
>> --Pierre O'Dee, self-appointed spokesman for the PSF
>>
>
>This is excellent news, no unicode means no chance of any performance 
>regressions whilst implementing stupid things like memory savings and 
>correctness.
>
>One question, why use a character encoding that's named after a very 
>famous French actress?
>
>-- 
>If you're using GoogleCrap™ please read this 
>http://wiki.python.org/moin/GoogleGroupsPython.
>
>Mark Lawrence
>
>-- 
>http://mail.python.org/mailman/listinfo/python-list

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread John Ladasky
On Monday, April 1, 2013 8:30:56 AM UTC-7, Pierre O'Dee wrote:

> Guido went on to say that he's now working on a new language
> called Giddy-up-and-Go which will take the worst features of C++,
> Java, and French combined with elements of both PHP and Klingon
> syntax. He said that this new endeavor should put the work and
> frustration back into programming "[where] it ought to be."

In other news, the famed University of Milan computer science professor Aprille 
Pazzo announced that she would be joining the Giddy-up-and-Go development team.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread llanitedave
Another detail about the new language: the Btrees used in Python's persistent 
object data structures have been replaced by...

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


Curl and python httplib?

2013-04-01 Thread ??????PHP
Guys,

I take a project that need send request to Hadoop by curl.
But now, the curl and pycurl can't satisfy my project. So i need use the 
powerful httplib.
But failed.


my curl request:
curl -i -X PUT "http://localhost:50070/webhdfs/v1/levi/7?op=CREATE";


my return:
HTTP/1.1 307 TEMPORARY_REDIRECT
Content-Type: application/octet-stream
Location: http://58.53.211.47:50075/webhdfs/v1/levi/7?op=CREATE&overwrite=false
Content-Length: 0
Server: Jetty(6.1.26)



Now, i change the curl request to httplib:
import httplib
import urllib


params=urllib.urlencode({"@op":"CREATE","@user.name":"levi"})
headers={"Content-type": "application/x-www-form-urlencoded","Accept": 
"text/plain"}
conn=httplib.HTTPConnection("localhost:50070")
conn.request("PUT","/webhdfs/v1/levi/7.txt",params,headers)
response=conn.getresponse()
print response.status, response.reason
data=response.read()

print data
conn.close()


But it failed:
#print response.status, response.reason
500 Internal Server Error
#print data
'{"RemoteException":{"exception":"WebApplicationException","javaClassName":"javax.ws.rs.WebApplicationException","message":null}}'


Who knows why? It's OK when i use curl, so where is the problem in httplib 
method?
Or some other reasons?
Who can help me change the curl request to httplib edition?


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


Re: round off to two decimal & return float

2013-04-01 Thread ஆமாச்சு
On Saturday 30 March 2013 03:14 PM, Peter Otten wrote:
> style = xlwt.XFStyle()
> style.num_format_str = "0.00"
Yes. That was really helpful & what I expected.

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


ISO deprecates ASCII Horizontal Tab control character

2013-04-01 Thread fsb
The subcommittee of ISO Joint Technical Committee 1 that is responsible for 
coded character sets has deprecated the Horizontal Tab control character in an 
approved revision of ISO/IEC 646 to be published in the next few months.

"The days of HT's usefulness in printer control are long gone," said Dr. 
Yishoki Makimi, chair of the subcommittee. "Today tabs are only used in 
software source code. Our research revealed they serve no function in software 
engineering other than to provoke arguments and therefore waste time. We 
measured that HTs accumulated economic cost surpassed that of big vs. 
little-endian byte order in 2007 and started the committee work to deprecate it 
shortly after that."

The width of a horizontal tab was originally adjustable in printer mechanism 
and was never standardized. Its subsequent use for indentation of instructions 
in the source code of block-oriented languages was economical when computer 
storage was expensive. Eventually many programmers adopted spaces leading to 
the contraversy that motivated the subcommittee.

Microsoft has responded to ISO's move by announcing that HT will contunue be 
supported in Windows through Version 8, after which the code point will be 
repurposed for the Windows Key. Hillary Jeremy, Microsoft's code quality and 
standards boss, welcomed the move saying, "We've probably spent more time, over 
the years, fighting over tabs than we have spent fixing bugs in Office."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread jmfauth
-


I'm not whining or and I'm not complaining (and never did).
I always exposed facts.

I'm not especially interested in Python, I'm interested in
Unicode.

Usualy when I posted examples, there are confirmed.


What I see is this (std "download-abled" Python's on Windows 7 (and
other
Windows/platforms/machines):

Py32
>>> import timeit
>>> timeit.repeat("'a' * 1000 + 'ẞ'")
[0.7005365263669056, 0.6810694766790423, 0.6811978680727229]
>>> timeit.repeat("'a' * 1000 + 'z'")
[0.7105829560031083, 0.6904999426964764, 0.6938637184431968]

Py33
import timeit
timeit.repeat("'a' * 1000 + 'ẞ'")
[1.1484035160337613, 1.1233738895227505, 1.1215708962703874]
timeit.repeat("'a' * 1000 + 'z'")
[0.6640958193635527, 0.6469043692851528, 0.645896142397]

I have systematically such a behaviour, in 99.9% of my tests.
When there is something better, it is usually because something else
(3.2/3.3) has been modified.

I have my idea where this is coming from.

Question: When it is claimed, that this has been tested,
do you mean stringbench.py as proposed many times by Terry?
(Thanks for an answer).

jmf

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


os.system() with imbeded quotes on centos

2013-04-01 Thread cevyne
I get the example os.system('ls -al') no problem.

i'm trying to create a variable with my command built in it but needs to 
include quotes.
Portion of code is as follows:
someip = '192.168.01.01'

var1 = 'lynx -dump http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++  
> junk' 

print  var1

os.system(var1)


If I print var1 it looks right .  If I use the os.system(var1) as above it 
seems to have a problem near the end of the string with msg 
sh: .submit=+++Go%21+++: command not found

clearly there is some escape sequence that I don't understand .

I tried combinations of single and double quotes and mixed around var1 in 
os.system(), but that generates command not found.  

I need it to look like how I enter it manually and works
lynx -dump 'http://192.168.01.01/cgi-bin/.log&.submit=+++Go%21+++  > junk' 

Probably obvious to many but i'm spinning my wheels.  many thanks for help .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 6:15 AM, jmfauth  wrote:
> Py32
 import timeit
 timeit.repeat("'a' * 1000 + 'ẞ'")
> [0.7005365263669056, 0.6810694766790423, 0.6811978680727229]
 timeit.repeat("'a' * 1000 + 'z'")
> [0.7105829560031083, 0.6904999426964764, 0.6938637184431968]
>
> Py33
> import timeit
> timeit.repeat("'a' * 1000 + 'ẞ'")
> [1.1484035160337613, 1.1233738895227505, 1.1215708962703874]
> timeit.repeat("'a' * 1000 + 'z'")
> [0.6640958193635527, 0.6469043692851528, 0.645896142397]

This is what's called a microbenchmark. Can you show me any instance
in production code where an operation like this is done repeatedly, in
a time-critical place? It's a contrived example, and it's usually
possible to find regressions in any system if you fiddle enough with
the example. Do you have, for instance, a web server that can handle
1000 tps on 3.2 and only 600 tps on 3.3, all other things being equal?

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Daneliuk

On 04/01/2013 10:30 AM, Pierre O'Dee wrote:

PSF [Beaverton, OR] 1 April 2013 -- At a news conference held


Amazing that this should show up when it did.  Just today, we
had Board Meeting at the intergalactic HQ of TundraWare Inc.
and finally decided to move forward with this project we'd
announced some time ago:

   http://compgroups.net/comp.lang.python/ann-yapdl/1638348


We would be pleased to cooperate with you in this new venture,
especially insofar as we too believe there is simply not
enough French linguistic construct in the modern programming
languages.

Merci,
Bon Chance,
A la bouffe,
---
Tim Daneliuk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Curl and python httplib?

2013-04-01 Thread Mark Lawrence

On 30/03/2013 05:08, Сѧ԰PHP wrote:

Guys,

I take a project that need send request to Hadoop by curl.
But now, the curl and pycurl can't satisfy my project. So i need use the
powerful httplib.
But failed.

*my curl request:*
curl -i -X PUT "http://localhost:50070/webhdfs/v1/levi/7?op=CREATE";

*my return:*
HTTP/1.1 307 TEMPORARY_REDIRECT
Content-Type: application/octet-stream
Location:
http://58.53.211.47:50075/webhdfs/v1/levi/7?op=CREATE&overwrite=false
Content-Length: 0
Server: Jetty(6.1.26)

*Now, i change the curl request to httplib:*
import httplib
import urllib

params=urllib.urlencode({"@op":"CREATE","@user.name":"levi"})
headers={"Content-type": "application/x-www-form-urlencoded","Accept":
"text/plain"}
conn=httplib.HTTPConnection("localhost:50070")
conn.request("PUT","/webhdfs/v1/levi/7.txt",params,headers)
response=conn.getresponse()
print response.status, response.reason
data=response.read()
print data
conn.close()

*But it failed:*
#print response.status, response.reason
500 Internal Server Error
#print data
'{"RemoteException":{"exception":"WebApplicationException","javaClassName":"javax.ws.rs.WebApplicationException","message":null}}'

Who knows why? It's OK when i use curl, so where is the problem in
httplib method?
Or some other reasons?
Who can help me change the curl request to httplib edition?

TIA
Levi




Try the requests module https://pypi.python.org/pypi/requests/ as if I 
can successfuly use it anybody can :)


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: os.system() with imbeded quotes on centos

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 6:22 AM,   wrote:
> var1 = 'lynx -dump http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++ 
>  > junk'
> lynx -dump 'http://192.168.01.01/cgi-bin/.log&.submit=+++Go%21+++  > junk'


The problem is the &, which splits the command. Note how your manual
execution puts single quotes around just the URL; in the other
version, you're not doing that. (Though I'm not entirely sure why your
> junk is inside the quotes - is that an error?) Try this:

var1 = 'lynx -dump "http://' + someip +
'/cgi-bin/.log&.submit=+++Go%21+++"  > junk'

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Mark Lawrence

On 01/04/2013 20:15, jmfauth wrote:

-


I'm not whining or and I'm not complaining (and never did).
I always exposed facts.


The only fact I'm aware of is an edge case that is being addressed on 
the Python bug tracker, sorry I'm too lazy to look up the number again.




I'm not especially interested in Python, I'm interested in
Unicode.


So why do you keep harping on about the same old edge case?



Usualy when I posted examples, there are confirmed.


The only thing you've ever posted are the same old boring micro 
benchmarks.  You never, ever comment on the memory savings that are IIRC 
extremely popular with the Django folks amongst others.  Neither do you 
comment on the fact that the unicode implementation in Python 3.3 is 
correct.  I can only assume that you prefer a fast but buggy 
implementation to a correct but slow one.  Except that in many cases the 
3.3 implementation is actually faster, so you conveniently ignore this.





What I see is this (std "download-abled" Python's on Windows 7 (and
other
Windows/platforms/machines):

Py32

import timeit
timeit.repeat("'a' * 1000 + 'ẞ'")

[0.7005365263669056, 0.6810694766790423, 0.6811978680727229]

timeit.repeat("'a' * 1000 + 'z'")

[0.7105829560031083, 0.6904999426964764, 0.6938637184431968]

Py33
import timeit
timeit.repeat("'a' * 1000 + 'ẞ'")
[1.1484035160337613, 1.1233738895227505, 1.1215708962703874]
timeit.repeat("'a' * 1000 + 'z'")
[0.6640958193635527, 0.6469043692851528, 0.645896142397]

I have systematically such a behaviour, in 99.9% of my tests.


Always run on your micro benchmarks, never anything else.


When there is something better, it is usually because something else
(3.2/3.3) has been modified.

I have my idea where this is coming from.


I know where this is coming from as it's been stated umpteen times on 
numerous threads.  As usual you simply ignore any facts that you feel 
like, particularly with respect to any real world use cases.




Question: When it is claimed, that this has been tested,
do you mean stringbench.py as proposed many times by Terry?
(Thanks for an answer).


I find it amusing that you ask for an answer but refuse point blank to 
provide answers yourself.  I suspect that you've bitten off more than 
you can chew.




jmf



--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Daneliuk

On 04/01/2013 01:32 PM, llanitedave wrote:

Another detail about the new language: the Btrees used in Python's persistent 
object data structures have been replaced by...

A SHRUBBERY!



I believe you mean "A 'oly shrubbery", do you not?

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


Re: ISO deprecates ASCII Horizontal Tab control character

2013-04-01 Thread David Robinow
If only


On Mon, Apr 1, 2013 at 3:10 PM,  wrote:

> The subcommittee of ISO Joint Technical Committee 1 that is responsible
> for coded character sets has deprecated the Horizontal Tab control
> character in an approved revision of ISO/IEC 646 to be published in the
> next few months.
>
> "The days of HT's usefulness in printer control are long gone," said Dr.
> Yishoki Makimi, chair of the subcommittee. "Today tabs are only used in
> software source code. Our research revealed they serve no function in
> software engineering other than to provoke arguments and therefore waste
> time. We measured that HTs accumulated economic cost surpassed that of big
> vs. little-endian byte order in 2007 and started the committee work to
> deprecate it shortly after that."
>
> The width of a horizontal tab was originally adjustable in printer
> mechanism and was never standardized. Its subsequent use for indentation of
> instructions in the source code of block-oriented languages was economical
> when computer storage was expensive. Eventually many programmers adopted
> spaces leading to the contraversy that motivated the subcommittee.
>
> Microsoft has responded to ISO's move by announcing that HT will contunue
> be supported in Windows through Version 8, after which the code point will
> be repurposed for the Windows Key. Hillary Jeremy, Microsoft's code quality
> and standards boss, welcomed the move saying, "We've probably spent more
> time, over the years, fighting over tabs than we have spent fixing bugs in
> Office."
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


youtube-dl, a YouTube downloader in Python

2013-04-01 Thread vasudevram

Folks may find this of interest, both from a programming and from an end-user 
point of view:

youtube-dl, a YouTube downloader in Python:

http://jugad2.blogspot.in/2013/03/youtube-dl-yourube-downloader-in-python.html

I tried it out and it worked well. Downloaded a few videos using it.

(The "rube" in the URL was a typo, I would have had to delete and re-enter the 
post to fix it - see the post for the details :)

- Vasudev Ram
www.dancingbison.com


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



Switching from Apche to LiteSpeed

2013-04-01 Thread Νίκος Γκρ33κ
Just today i changed from HostGator to EZPZ, which means from Apache Web Server 
to LiteSpeed.

Does anyone know why iam seeing what iam seeing at http://superhost.gr

I see weird encoding although inside my python script i have:

#!/usr/bin/python
# -*- coding=utf-8 -*

Also dod you advise me to switch to VPS because none of the above webhosters is 
willing to support Python3 + MySQLdb ?

With VPS i could isntall those packages myself and any other module i wish via 
'pip install module'

What do you think?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system() with imbeded quotes on centos

2013-04-01 Thread John Gordon
In <0c9717ca-52dd-49ce-8102-e14328838...@googlegroups.com> cev...@gmail.com 
writes:

> someip = '192.168.01.01'
> var1 = 'lynx -dump http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++ 
>  > junk' 

'&' is a special character in shell commands.  You'll need to quote or
escape it.

Try this:

someip = '192.168.01.01'
var1 = 'lynx -dump "http://' + someip + 
'/cgi-bin/.log&.submit=+++Go%21+++"  > junk' 

Note the extra pair of double-quotes around the http:// part.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Performance of int/long in Python 3

2013-04-01 Thread jmfauth
On 1 avr, 21:28, Chris Angelico  wrote:
> On Tue, Apr 2, 2013 at 6:15 AM, jmfauth  wrote:
> > Py32
>  import timeit
>  timeit.repeat("'a' * 1000 + 'ẞ'")
> > [0.7005365263669056, 0.6810694766790423, 0.6811978680727229]
>  timeit.repeat("'a' * 1000 + 'z'")
> > [0.7105829560031083, 0.6904999426964764, 0.6938637184431968]
>
> > Py33
> > import timeit
> > timeit.repeat("'a' * 1000 + 'ẞ'")
> > [1.1484035160337613, 1.1233738895227505, 1.1215708962703874]
> > timeit.repeat("'a' * 1000 + 'z'")
> > [0.6640958193635527, 0.6469043692851528, 0.645896142397]
>
> This is what's called a microbenchmark. Can you show me any instance
> in production code where an operation like this is done repeatedly, in
> a time-critical place? It's a contrived example, and it's usually
> possible to find regressions in any system if you fiddle enough with
> the example. Do you have, for instance, a web server that can handle
> 1000 tps on 3.2 and only 600 tps on 3.3, all other things being equal?
>
> ChrisA

-

Of course this is an example, as many I gave. Examples you may find in
apps.

Can you point and give at least a bunch of examples, showing
there is no regression, at least to contradict me. The only
one I succeed to see (in month), is the one given by Steven, a status
quo.

I will happily accept them. The only think I read is "this is faster",
"it has been tested", ...

jmf

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


Re: Switching from Apche to LiteSpeed

2013-04-01 Thread John Gordon
In <9a35850a-7fcb-4585-84ae-5e13cef91...@googlegroups.com> 
=?ISO-8859-7?B?zd/q7/Igw+rxMzPq?=  writes:

> Just today i changed from HostGator to EZPZ, which means from Apache Web 
> Server to LiteSpeed.

> Does anyone know why iam seeing what iam seeing at http://superhost.gr

> I see weird encoding although inside my python script i have:

> #!/usr/bin/python
> # -*- coding=utf-8 -*

I believe the syntax is to use a colon, not an equal sign.  i.e.:

# -*- coding: utf-8 -*-

Your example is also missing the final dash after the asterisk.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Roy Smith
In article <5159beb6$0$29967$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano   wrote:
>> The import job isn't done yet, but so far we've processed 116 million
>> records and had to clean up four of them.  I can live with that.
>> Sometimes practicality trumps correctness.
>
>Well, true. It has to be said that few programming languages (and 
>databases) make it easy to do the right thing. On the other hand, you're 
>a programmer. Your job is to write correct code, not easy code.

This is really getting off topic, but fundamentally, I'm an engineer.
My job is to build stuff that make money for my company.  That means
making judgement calls about what's not worth fixing, because the cost
to fix it exceeds the value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Switching from Apche to LiteSpeed

2013-04-01 Thread Mark Lawrence

On 01/04/2013 21:09, Νίκος Γκρ33κ wrote:

Just today i changed from HostGator to EZPZ, which means from Apache Web Server 
to LiteSpeed.

Does anyone know why iam seeing what iam seeing at http://superhost.gr

I see weird encoding although inside my python script i have:

#!/usr/bin/python
# -*- coding=utf-8 -*

Also dod you advise me to switch to VPS because none of the above webhosters is 
willing to support Python3 + MySQLdb ?

With VPS i could isntall those packages myself and any other module i wish via 
'pip install module'

What do you think?



I think you should get your cheque book out and make a donation to the PSF.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 7:28 AM, jmfauth  wrote:
> Of course this is an example, as many I gave. Examples you may find in
> apps.
>

Show me an *entire app* that suffers.

Show me one.

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


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread llanitedave
On Monday, April 1, 2013 12:59:04 PM UTC-7, Tim Daneliuk wrote:
> On 04/01/2013 01:32 PM, llanitedave wrote:
> 
> > Another detail about the new language: the Btrees used in Python's 
> > persistent object data structures have been replaced by...
> 
> >
> 
> > A SHRUBBERY!
> 
> >
> 
> 
> 
> I believe you mean "A 'oly shrubbery", do you not?
> 
> 
> 
> -- 
> 
> ---
> 
> Tim Daneliuk

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Mark Lawrence

On 01/04/2013 21:35, Chris Angelico wrote:

On Tue, Apr 2, 2013 at 7:28 AM, jmfauth  wrote:

Of course this is an example, as many I gave. Examples you may find in
apps.



Show me an *entire app* that suffers.

Show me one.

ChrisA



Please don't hold your breath.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Performance of int/long in Python 3

2013-04-01 Thread Mark Lawrence

On 01/04/2013 21:28, jmfauth wrote:

On 1 avr, 21:28, Chris Angelico  wrote:

On Tue, Apr 2, 2013 at 6:15 AM, jmfauth  wrote:

Py32

import timeit
timeit.repeat("'a' * 1000 + 'ẞ'")

[0.7005365263669056, 0.6810694766790423, 0.6811978680727229]

timeit.repeat("'a' * 1000 + 'z'")

[0.7105829560031083, 0.6904999426964764, 0.6938637184431968]



Py33
import timeit
timeit.repeat("'a' * 1000 + 'ẞ'")
[1.1484035160337613, 1.1233738895227505, 1.1215708962703874]
timeit.repeat("'a' * 1000 + 'z'")
[0.6640958193635527, 0.6469043692851528, 0.645896142397]


This is what's called a microbenchmark. Can you show me any instance
in production code where an operation like this is done repeatedly, in
a time-critical place? It's a contrived example, and it's usually
possible to find regressions in any system if you fiddle enough with
the example. Do you have, for instance, a web server that can handle
1000 tps on 3.2 and only 600 tps on 3.3, all other things being equal?

ChrisA


-

Of course this is an example, as many I gave. Examples you may find in
apps.


You've given many examples of the same type of micro benchmark, not many 
examples of different types of benchmark.




Can you point and give at least a bunch of examples, showing
there is no regression, at least to contradict me. The only
one I succeed to see (in month), is the one given by Steven, a status
quo.


Once again you deliberately choose to ignore the memory saving and 
correctness to concentrate on the performance slowdown in some cases.




I will happily accept them. The only think I read is "this is faster",
"it has been tested", ...



I do not believe that you will ever accept any facts unless you yourself 
provide them.



jmf




--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Help

2013-04-01 Thread khaosyt
Self-bump
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread khaosyt
Self-bump
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Mark Lawrence

On 01/04/2013 22:42, khao...@gmail.com wrote:

Self-bump



It's considered polite to wait for at least 24 hours before bumping a 
question.  You might have got more answers if you'd given a decent 
subject line rather than "Help".


As it happens all you need do is loop around the string that is input, 
converting every digit to an integer and storing them in a list, then 
call the builtin sum function against the stored list.


You'll probably also need a try/except to handle any duff input.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Curl and python httplib?

2013-04-01 Thread vasudevram
On Tuesday, April 2, 2013 1:03:58 AM UTC+5:30, Mark Lawrence wrote:
> On 30/03/2013 05:08, Сѧ԰PHP wrote:
> 
> > Guys,
> 
> >
> 
> > I take a project that need send request to Hadoop by curl.
> 
> > But now, the curl and pycurl can't satisfy my project. So i need use the
> 
> > powerful httplib.
> 
> > But failed.
> 
> >
> 
> > *my curl request:*
> 
> > curl -i -X PUT "http://localhost:50070/webhdfs/v1/levi/7?op=CREATE";
> 
> >
> 
> > *my return:*
> 
> > HTTP/1.1 307 TEMPORARY_REDIRECT
> 
> > Content-Type: application/octet-stream
> 
> > Location:
> 
> > http://58.53.211.47:50075/webhdfs/v1/levi/7?op=CREATE&overwrite=false
> 
> > Content-Length: 0
> 
> > Server: Jetty(6.1.26)
> 
> >
> 
> > *Now, i change the curl request to httplib:*
> 
> > import httplib
> 
> > import urllib
> 
> >
> 
> > params=urllib.urlencode({"@op":"CREATE","@user.name":"levi"})
> 
> > headers={"Content-type": "application/x-www-form-urlencoded","Accept":
> 
> > "text/plain"}
> 
> > conn=httplib.HTTPConnection("localhost:50070")
> 
> > conn.request("PUT","/webhdfs/v1/levi/7.txt",params,headers)
> 
> > response=conn.getresponse()
> 
> > print response.status, response.reason
> 
> > data=response.read()
> 
> > print data
> 
> > conn.close()
> 
> >
> 
> > *But it failed:*
> 
> > #print response.status, response.reason
> 
> > 500 Internal Server Error
> 
> > #print data
> 
> > '{"RemoteException":{"exception":"WebApplicationException","javaClassName":"javax.ws.rs.WebApplicationException","message":null}}'
> 
> >
> 
> > Who knows why? It's OK when i use curl, so where is the problem in
> 
> > httplib method?
> 
> > Or some other reasons?
> 
> > Who can help me change the curl request to httplib edition?
> 
> >
> 
> > TIA
> 
> > Levi
> 
> >
> 
> >
> 
> 
> 
> Try the requests module https://pypi.python.org/pypi/requests/ as if I 
> 
> can successfuly use it anybody can :)
> 
> 
> 
> -- 
> 
> If you're using GoogleCrap™ please read this 
> 
> http://wiki.python.org/moin/GoogleGroupsPython.
> 
> 
> 
> Mark Lawrence

Or try httplib2

GIYF

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


Re: Help

2013-04-01 Thread khaosyt
On Monday, April 1, 2013 6:09:04 PM UTC-4, Mark Lawrence wrote:
> On 01/04/2013 22:42, khao...@gmail.com wrote:
> 
> > Self-bump
> 
> >
> 
> 
> 
> It's considered polite to wait for at least 24 hours before bumping a 
> 
> question.  You might have got more answers if you'd given a decent 
> 
> subject line rather than "Help".
> 
> 
> 
> As it happens all you need do is loop around the string that is input, 
> 
> converting every digit to an integer and storing them in a list, then 
> 
> call the builtin sum function against the stored list.
> 
> 
> 
> You'll probably also need a try/except to handle any duff input.
> 
> 
> 
> -- 
> 
> If you're using GoogleCrap™ please read this 
> 
> http://wiki.python.org/moin/GoogleGroupsPython.
> 
> 
> 
> Mark Lawrence

How do I go about storing them in a list?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread John Gordon
In  khao...@gmail.com 
writes:

> If I wanted to get the sum of some numbers (for example: 1 + 2 + 3 + 4
> + 5 = 15) from the attached program what do I do? Keep in mind that the
> print statement prints the integers individually. 

It's not clear what you're asking for.  The attached program doesn't
(appear to) work with sums at all; why would you want to use it?
Writing a new program from scratch would seem to be a better choice.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Help

2013-04-01 Thread khaosyt
On Monday, April 1, 2013 6:12:43 PM UTC-4, John Gordon wrote:
> In  khao...@gmail.com 
> writes:
> 
> 
> 
> > If I wanted to get the sum of some numbers (for example: 1 + 2 + 3 + 4
> 
> > + 5 = 15) from the attached program what do I do? Keep in mind that the
> 
> > print statement prints the integers individually. 
> 
> 
> 
> It's not clear what you're asking for.  The attached program doesn't
> 
> (appear to) work with sums at all; why would you want to use it?
> 
> Writing a new program from scratch would seem to be a better choice.
> 
> 
> 
> -- 
> 
> John Gordon   A is for Amy, who fell down the stairs
> 
> gor...@panix.com  B is for Basil, assaulted by bears
> 
> -- Edward Gorey, "The Gashlycrumb Tinies"

It doesn't work with sums yet; it only returns individual positive integers in 
a longer number. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Dave Angel

On 04/01/2013 05:42 PM, khao...@gmail.com wrote:

Self-bump



Normally, bumping a message/thread means replying to it.  You're leaving 
a NEW message with no context, no reply, and a different uninformative 
subject line.  And you're leaving it from googlegroups, with two copies.


If you want to sum things through a loop, initialize a variable to zero 
before the loop, then add to it each time through the loop.


total=0
for  whatever in something:
total += whatever_expression

print total


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


Re: Help

2013-04-01 Thread Mark Lawrence

On 01/04/2013 23:12, khao...@gmail.com wrote:

On Monday, April 1, 2013 6:09:04 PM UTC-4, Mark Lawrence wrote:

On 01/04/2013 22:42, khao...@gmail.com wrote:


Self-bump








It's considered polite to wait for at least 24 hours before bumping a

question.  You might have got more answers if you'd given a decent

subject line rather than "Help".



As it happens all you need do is loop around the string that is input,

converting every digit to an integer and storing them in a list, then

call the builtin sum function against the stored list.



You'll probably also need a try/except to handle any duff input.



--

If you're using GoogleCrap™ please read this

http://wiki.python.org/moin/GoogleGroupsPython.



Mark Lawrence


How do I go about storing them in a list?



Read this http://docs.python.org/3/tutorial/introduction.html#lists

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Help

2013-04-01 Thread John Gordon
In <118e161a-4981-4696-8bdb-780bf8248...@googlegroups.com> khao...@gmail.com 
writes:

> > It's not clear what you're asking for.  The attached program doesn't
> > (appear to) work with sums at all; why would you want to use it?
> > Writing a new program from scratch would seem to be a better choice.

> It doesn't work with sums yet; it only returns individual positive
> integers in a longer number. 

Yes, I can see that.  But your original request said that you wanted to
get a sum of numbers "from the attached program", which sort of implies
that you want to use the program exactly as it was posted, without
modifications.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Get multiprocessing.Queue to do priorities

2013-04-01 Thread madeleine . udell
Was this issue ever resolved? What is the current best practice for those 
wishing to use a priority queue with multiprocessing?

On Sunday, May 10, 2009 6:35:03 AM UTC-7, Jesse Noller wrote:
> On Sat, May 9, 2009 at 6:11 PM, uuid  wrote:
> > The Queue module, apparently, is thread safe, but *not* process safe. If you
> > try to use an ordinary Queue, it appears inaccessible to the worker process.
> > (Which, after all, is quite logical, since methods for moving items between
> > the threads of the same process are quite different from inter-process
> > communication.) It appears that creating a manager that holds a shared queue
> > might be an option
> > (http://stackoverflow.com/questions/342556/python-2-6-multiprocessing-queue-compatible-with-threads).
> 
> Using a manager, or submitting a patch which adds priority queue to
> the multiprocessing.queue module is the correct solution for this.
> 
> You can file an enhancement in the tracker, and assign/add me to it,
> but without a patch it may take me a bit (wicked busy right now).
> 
> jesse

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


Re: Help

2013-04-01 Thread khaosyt
On Monday, April 1, 2013 6:33:08 PM UTC-4, John Gordon wrote:
> In <118e161a-4981-4696-8bdb-780bf8248...@googlegroups.com> khao...@gmail.com 
> writes:
> 
> 
> 
> > > It's not clear what you're asking for.  The attached program doesn't
> 
> > > (appear to) work with sums at all; why would you want to use it?
> 
> > > Writing a new program from scratch would seem to be a better choice.
> 
> 
> 
> > It doesn't work with sums yet; it only returns individual positive
> 
> > integers in a longer number. 
> 
> 
> 
> Yes, I can see that.  But your original request said that you wanted to
> 
> get a sum of numbers "from the attached program", which sort of implies
> 
> that you want to use the program exactly as it was posted, without
> 
> modifications.
> 
> 
> 
> -- 
> 
> John Gordon   A is for Amy, who fell down the stairs
> 
> gor...@panix.com  B is for Basil, assaulted by bears
> 
> -- Edward Gorey, "The Gashlycrumb Tinies"

I want to modify it so it can be used to find the sums.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 23:09:04 +0100, Mark Lawrence wrote:

> On 01/04/2013 22:42, khao...@gmail.com wrote:
>> Self-bump
>>
>>
> It's considered polite to wait for at least 24 hours before bumping a
> question.

Yes, but the assignment is due in an hour. Therefore it's critical that 
we reply instantly.

*wink*


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


Re: Help

2013-04-01 Thread Roy Smith
In article <515a1b7c$0$29967$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> On Mon, 01 Apr 2013 23:09:04 +0100, Mark Lawrence wrote:
> 
> > On 01/04/2013 22:42, khao...@gmail.com wrote:
> >> Self-bump
> >>
> >>
> > It's considered polite to wait for at least 24 hours before bumping a
> > question.
> 
> Yes, but the assignment is due in an hour. Therefore it's critical that 
> we reply instantly.

How do you know it's an assignment?  It could be an interview.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance of int/long in Python 3

2013-04-01 Thread Neil Hodgson

Mark Lawrence:


You've given many examples of the same type of micro benchmark, not many
examples of different types of benchmark.


   Trying to work out what jmfauth is on about I found what appears to 
be a performance regression with '<' string comparisons on Windows 
64-bit. Its around 30% slower on a 25 character string that differs in 
the last character and 70-100% on a 100 character string that differs at 
the end.


   Can someone else please try this to see if its reproducible? Linux 
doesn't show this problem.


>c:\python32\python -u "charwidth.py"
3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)]
a=['C:/Users/Neil/Documents/b','C:/Users/Neil/Documents/z']176
[0.7116295577956576, 0.7055591343157613, 0.7203483026429418]

a=['C:/Users/Neil/Documents/λ','C:/Users/Neil/Documents/η']176
[0.7664397841378787, 0.7199902325464409, 0.713719289812504]

a=['C:/Users/Neil/Documents/b','C:/Users/Neil/Documents/η']176
[0.7341851791817691, 0.6994205901833599, 0.7106807593741005]

a=['C:/Users/Neil/Documents/𠀀','C:/Users/Neil/Documents/𠀁']180
[0.7346812372666784, 0.699543377914, 0.7064768417728411]

>c:\python33\python -u "charwidth.py"
3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit 
(AMD64)]

a=['C:/Users/Neil/Documents/b','C:/Users/Neil/Documents/z']108
[0.9913326076446045, 0.9455845241056282, 0.9459076605341776]

a=['C:/Users/Neil/Documents/λ','C:/Users/Neil/Documents/η']192
[1.0472289217234318, 1.0362342484091207, 1.0197109728048384]

a=['C:/Users/Neil/Documents/b','C:/Users/Neil/Documents/η']192
[1.0439643704533834, 0.9878581050301687, 0.9949265834034335]

a=['C:/Users/Neil/Documents/𠀀','C:/Users/Neil/Documents/𠀁']312
[1.0987483965446412, 1.0130257167690004, 1.024832248526499]

   Here is the code:

# encoding:utf-8
import os, sys, timeit
print(sys.version)
examples = [
"a=['$b','$z']",
"a=['$λ','$η']",
"a=['$b','$η']",
"a=['$\U0002','$\U00020001']"]
baseDir = "C:/Users/Neil/Documents/"
#~ baseDir = "C:/Users/Neil/Documents/Visual Studio 
2012/Projects/Sigma/QtReimplementation/HLFKBase/Win32/x64/Debug"

for t in examples:
t = t.replace("$", baseDir)
# Using os.write as simple way get UTF-8 to stdout
os.write(sys.stdout.fileno(), t.encode("utf-8"))
print(sys.getsizeof(t))
print(timeit.repeat("a[0] < a[1]",t,number=500))
print()

   For a more significant performance difference try replacing the 
baseDir setting with (may be wrapped):
baseDir = "C:/Users/Neil/Documents/Visual Studio 
2012/Projects/Sigma/QtReimplementation/HLFKBase/Win32/x64/Debug"


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


Re: Creating a dictionary from a .txt file

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 11:41:03 +, Neil Cerutti wrote:


> I tried searching for Frost*, an interesting artist I recently learned
> about. 

"Interesting artist" -- is that another term for "wanker"?

*wink*


> His name, in combination with a similarly named rap artist,
> breaks most search tools.

As far as I'm concerned, anyone in the 21st century who names themselves 
or their work (a movie, book, programming language, etc.) something which 
breaks search tools is just *begging* for obscurity, and we ought to 
respect their wishes.


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


Re: Help

2013-04-01 Thread khaosyt
On Monday, April 1, 2013 7:47:51 PM UTC-4, Roy Smith wrote:
> In article <515a1b7c$0$29967$c3e8da3$54964...@news.astraweb.com>,
> 
>  Steven D'Aprano  wrote:
> 
> 
> 
> > On Mon, 01 Apr 2013 23:09:04 +0100, Mark Lawrence wrote:
> 
> > 
> 
> > > On 01/04/2013 22:42, khao...@gmail.com wrote:
> 
> > >> Self-bump
> 
> > >>
> 
> > >>
> 
> > > It's considered polite to wait for at least 24 hours before bumping a
> 
> > > question.
> 
> > 
> 
> > Yes, but the assignment is due in an hour. Therefore it's critical that 
> 
> > we reply instantly.
> 
> 
> 
> How do you know it's an assignment?  It could be an interview.

It's an assignment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a dictionary from a .txt file

2013-04-01 Thread C.T.
Thanks for all the help everyone! After I manually edited the txt file, this is 
what I came up with:

car_dict = {}
car_file = open('cars.txt', 'r')


 
for line in car_file: 
temp = line.strip().split(None, 2)
temp2 = line.strip().split('\t')


if len(temp)==3:  
year, manufacturer, model = temp[0] ,temp2[0][5:], temp2[1]
value = (year, model)
if manufacturer in car_dict:
car_dict.setdefault(manufacturer,[]).append(value)
else:
car_dict[manufacturer] = [value]


elif len(temp)==2:
year, manufacturer, model = temp[0], 'Unknown' , temp2[1]
value = (year, model)
if manufacturer in car_dict:
car_dict.setdefault(manufacturer,[]).append(value)
else:
car_dict[manufacturer] = [value]


car_file.close()

print (car_dict)

It may not be the most pythonic way of doing this, but it works for me. I am 
learning python, and this problem was problem the most challenging so far. 
Thank you all, again!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Walter Hurry
On Mon, 01 Apr 2013 15:12:20 -0700, khaosyt wrote:



Sigh. Another one for the bozo bin.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 14:44:45 -0700, khaosyt wrote:

> If I wanted to get the sum of some numbers (for example: 1 + 2 + 3 + 4 +
> 5 = 15) from the attached program what do I do? Keep in mind that the
> print statement prints the integers individually.


Yes, we know what the print statement does. Some of us have been using 
Python for weeks now.


Some comments interspersed within your code below:



> integer = 0
> denom = 10
> again = "y" #sentinel:

Technically, that's not a sentinel.

> while again == "y" or again == "Y":
> integer = input("Enter a positive integer: ")

I believe that the last time you asked this question, you were told not 
to use the "input" function as it was dangerous or can lead to hard-to-
understand bugs. Change the above line to:

integer = raw_input("Enter a positive integer: ")


Notice that if you do this, the so-called "integer" is actually a string. 
This is a good thing! You want it as a string, since that makes it easy 
to extract individual digits.


> while denom <= integer:
> denom = denom*10
> while denom > 1:
> denom = denom/10
> number = integer/denom
> integer = integer%denom
> print str(number)

All this stuff with denom seems to be aimed at extracting the digits from 
a number. There's an easier way: just work with the string.

After the line I suggested above 

integer = raw_input("Enter a positive integer: ")


"integer" is a string of digits. So you can iterate over the digits using 
a for-loop:

# this is not what you want!
for digit in integer:
print digit


Instead of printing the digits, you want to add them up. So start by 
initialising a total, then add them:

total = 0
for digit in integer:
total = total + digit


Warning! The above three lines contains a bug. If you make the changes I 
suggest, and try it, you will get an error. That's okay. Read the error. 
Try to understand what it is telling you. Hint: remember that total is an 
actual int, a number, while each digit is a single character, a string.

You need to convert each digit into a number before adding it. Hint: the 
int function takes a string, and converts it to a number.

py> 42 + "23"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'int' and 'str'
py> 42 + int("23")
65


This should hopefully give you enough information to get some working 
code. Try to write as much of the code as you can, and come back with any 
further questions *after* making a good effort.

Another hint: try experimenting at the interactive interpreter, or IDLE. 
If you're unsure about something, try it and see what happens *before* 
asking.


Good luck.




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


Re: Help please

2013-04-01 Thread Steven D'Aprano
On Sun, 31 Mar 2013 22:41:32 -0700, khaosyt wrote:

> On Monday, April 1, 2013 1:24:52 AM UTC-4, Chris Angelico wrote:
>> On Mon, Apr 1, 2013 at 4:15 PM,   wrote:
>> 
>> > integer = input("Enter a positive integer: ")
>> 
>> > again = raw_input("Again? (Y/N): ")
>> 
>> 
>> 
>> Okay, the first thing I'm going to say is: Don't use input() in Python
>> 
>> 2. It's dangerous in ways you won't realize. Use int(raw_input(...))

[...]

> Elaborate, please.


The input() function takes the user's text, and automatically evaluates 
it as if it were code. In the hands of a non-expert, that can lead to 
some unexpected errors:

py> answer = input("what is your name? ")
what is your name? Steve
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'Steve' is not defined



But at least that gives you an error. It can also give you weird and 
unexpected results. Suppose my name was Lenny, and I did this:

py> answer = input("what is your name? ")
what is your name? len
py> print answer




Worse, because input evaluates text as code, it can do anything, 
including bad things:

py> answer = input("what is your name? ")
what is your name? 200**300**300
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
MemoryError


(while the above code was running, my computer got slower and slower and 
slower, and potentially it could have locked up completely).


So the general advice is, treat the input() function as For Experts Only, 
and always use raw_input() instead.




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


Re: Creating a dictionary from a .txt file

2013-04-01 Thread Dave Angel

On 04/01/2013 07:53 PM, C.T. wrote:

Thanks for all the help everyone! After I manually edited the txt file, this is 
what I came up with:

car_dict = {}
car_file = open('cars.txt', 'r')



for line in car_file:
 temp = line.strip().split(None, 2)
 temp2 = line.strip().split('\t')


 if len(temp)==3:
 year, manufacturer, model = temp[0] ,temp2[0][5:], temp2[1]
 value = (year, model)
 if manufacturer in car_dict:
 car_dict.setdefault(manufacturer,[]).append(value)


That's rather redundant.  Once you've determined that the particular key 
is already there, why bother with the setdefault() call?  Or to put it 
another way, why bother to test if it's there when you're going to use 
setdefault to handle the case where it's not?




 else:
 car_dict[manufacturer] = [value]


 elif len(temp)==2:
 year, manufacturer, model = temp[0], 'Unknown' , temp2[1]
 value = (year, model)
 if manufacturer in car_dict:
 car_dict.setdefault(manufacturer,[]).append(value)
 else:
 car_dict[manufacturer] = [value]


car_file.close()

print (car_dict)

It may not be the most pythonic way of doing this, but it works for me. I am 
learning python, and this problem was problem the most challenging so far. 
Thank you all, again!




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


Re: Creating a dictionary from a .txt file

2013-04-01 Thread Walter Hurry
On Mon, 01 Apr 2013 23:53:40 +, Steven D'Aprano wrote:

> As far as I'm concerned, anyone in the 21st century who names themselves
> or their work (a movie, book, programming language, etc.) something
> which breaks search tools is just *begging* for obscurity, and we ought
> to respect their wishes.

IIRC, there was an eccentric musician some years back who did just that.

I seem to remember that he changed his name to some kind of androgynous 
looking rune with what appeared to be a bent trumpet across it.

Thenceforth it became known as "the (piss) artist: formally gnome ass 
prints", or at least something sounding vaguely like that.


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


Re: Help

2013-04-01 Thread khaosyt
On Monday, April 1, 2013 8:00:30 PM UTC-4, Steven D'Aprano wrote:
> On Mon, 01 Apr 2013 14:44:45 -0700, khaosyt wrote:
> 
> 
> 
> > If I wanted to get the sum of some numbers (for example: 1 + 2 + 3 + 4 +
> 
> > 5 = 15) from the attached program what do I do? Keep in mind that the
> 
> > print statement prints the integers individually.
> 
> 
> 
> 
> 
> Yes, we know what the print statement does. Some of us have been using 
> 
> Python for weeks now.
> 
> 
> 
> 
> 
> Some comments interspersed within your code below:
> 
> 
> 
> 
> 
> 
> 
> > integer = 0
> 
> > denom = 10
> 
> > again = "y" #sentinel:
> 
> 
> 
> Technically, that's not a sentinel.
> 
> 
> 
> > while again == "y" or again == "Y":
> 
> > integer = input("Enter a positive integer: ")
> 
> 
> 
> I believe that the last time you asked this question, you were told not 
> 
> to use the "input" function as it was dangerous or can lead to hard-to-
> 
> understand bugs. Change the above line to:
> 
> 
> 
> integer = raw_input("Enter a positive integer: ")
> 
> 
> 
> 
> 
> Notice that if you do this, the so-called "integer" is actually a string. 
> 
> This is a good thing! You want it as a string, since that makes it easy 
> 
> to extract individual digits.
> 
> 
> 
> 
> 
> > while denom <= integer:
> 
> > denom = denom*10
> 
> > while denom > 1:
> 
> > denom = denom/10
> 
> > number = integer/denom
> 
> > integer = integer%denom
> 
> > print str(number)
> 
> 
> 
> All this stuff with denom seems to be aimed at extracting the digits from 
> 
> a number. There's an easier way: just work with the string.
> 
> 
> 
> After the line I suggested above 
> 
> 
> 
> integer = raw_input("Enter a positive integer: ")
> 
> 
> 
> 
> 
> "integer" is a string of digits. So you can iterate over the digits using 
> 
> a for-loop:
> 
> 
> 
> # this is not what you want!
> 
> for digit in integer:
> 
> print digit
> 
> 
> 
> 
> 
> Instead of printing the digits, you want to add them up. So start by 
> 
> initialising a total, then add them:
> 
> 
> 
> total = 0
> 
> for digit in integer:
> 
> total = total + digit
> 
> 
> 
> 
> 
> Warning! The above three lines contains a bug. If you make the changes I 
> 
> suggest, and try it, you will get an error. That's okay. Read the error. 
> 
> Try to understand what it is telling you. Hint: remember that total is an 
> 
> actual int, a number, while each digit is a single character, a string.
> 
> 
> 
> You need to convert each digit into a number before adding it. Hint: the 
> 
> int function takes a string, and converts it to a number.
> 
> 
> 
> py> 42 + "23"
> 
> Traceback (most recent call last):
> 
>   File "", line 1, in 
> 
> TypeError: unsupported operand type(s) for +: 'int' and 'str'
> 
> py> 42 + int("23")
> 
> 65
> 
> 
> 
> 
> 
> This should hopefully give you enough information to get some working 
> 
> code. Try to write as much of the code as you can, and come back with any 
> 
> further questions *after* making a good effort.
> 
> 
> 
> Another hint: try experimenting at the interactive interpreter, or IDLE. 
> 
> If you're unsure about something, try it and see what happens *before* 
> 
> asking.
> 
> 
> 
> 
> 
> Good luck.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Thanks. I'll try it out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help

2013-04-01 Thread Mark Lawrence

On 02/04/2013 00:56, Walter Hurry wrote:

On Mon, 01 Apr 2013 15:12:20 -0700, khaosyt wrote:



Sigh. Another one for the bozo bin.



I say old chap you're setting yourself up for attacks from the Python 
Mailing List Police for using the word bozo, so expect a visit from 
Vicar Sergeant or Detective Parsons.  Oh sorry they're from the Church 
Police, but please be cautious anyway.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


python mock Requests and the response

2013-04-01 Thread usmani . kashif9957
I am a beginner to using mock in python and trying to use 
http://www.voidspace.org.uk/python/mock.

Please tell me the basic calls to get me working in below scenario. I am using 
python's Requests module (http://docs.python-requests.org/en/latest/) .

In my views.py, I have a function that makes variety of requests.get() calls 
with different response each time

def myview(request):
  res1 = requests.get('aurl')
  res2 = request.get('burl')
  res3 = request.get('curl')

In my test class I want to do something like this but cannot figure out exact 
method calls

Step 1:

//Mock the requests module
//when mockedRequests.get('aurl') is called then return 'a response'
//when mockedRequests.get('burl') is called then return 'b response'
//when mockedRequests.get('curl') is called then return 'C response'

Step 2:

Call my view

Step 3: 

verify response contains 'a response', 'b response' , 'c response'

Please help me to complete Step 1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python install Win 7 Problem

2013-04-01 Thread rusi
On Apr 2, 6:02 am, Joe Hill  wrote:
> Python install Win 7 Problem
>
> This is some of what others have experienced attempting to install Python
> in Win 7  - I'm attempting to do the same with hopefully fewer detours.
>
> http://www.andrewsturges.com/2012/05/installing-numpy-for-python-3-in...
> It's time to do some scientific computing, which, in the Python world,
> means using NumPy. I'm in a Windows 7 (64-bit) environment running Python
> 3.2.3 (64-bit).
>
> Getting NumPy installed for Python 2 or Python 3 in Ubuntu was easy.
> Getting it to work in Windows turned out to be more tricky.
> The Short Takeaway
>
>     In a Windows 7 environment (even a 64-bit Windows 7 environment), you
> must install the 32-bit version of Python 3. The 64-bit version will not
> work with NumPy 1.6.

Not claiming I can be of much help. Still...
I dont see in your description, which numpy you used.
Did you use this?
http://www.scipy.org/Download#head-f64942d62faddeb27278a2c735e81ef2a7349db0
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Tim Roberts
morphex  wrote:
>
>While we're on the subject, wouldn't it be nice to have some cap there so
>that it isn't possible to more or less block the system with large 
>exponentiation?

There IS a cap.  It's called the "MemoryError" exception.

But, seriously, what would you have it do instead?
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a simple stand alone python app I can use on my Kindle fire?

2013-04-01 Thread Tim Roberts
ah  wrote:
>
>I'm enjoying learning python, and would like to be able to study and practice 
>on the go, using my kindle fire reader. (wifi enabled).
>
>Amazon does have an app, Qpython lite, but requires a  live wifi connection
>to the internet to run. I'm looking for a simple python app, stand alone 
>that i can run on my kindle, without an internet connection,  just to 
>practice while i learn. (Just a simple terminal, and text editor, and
>python? like ubuntu offers.)

You have identified the ingredients: you need a shell, you need an editor,
and you need the Python interpreter.

Your Kindle is an Android device, which means it runs Linux, but I don't
know whether you have access to the general Android app store.  There
certainly are Android terminal applications available that will bring up a
shell for you.  The one you have is probably enough.

There is also an implemention of Vim for Android that even supports touch
commands.  If you've played with Ubuntu, then you probably already know
Vim.

After that, you'll need Python itself.  Your machine has an ARM processor,
so you'll want to find a Python built for Linux ARM.  I know such things
are available, but you may have to do some creative searching.

Just like Ubuntu, you cannot run Windows applications.  You also cannot run
any x86 or amd64 applications.  You must have ARM binaries.  If you want to
go really crazy, you can get a "cross compiler" for your Ubuntu system that
lets you build ARM binaries.  From there, you could build Python from
source.


>I've tried downloading portable python, and couldnt' get it to run 
>('can't run in DOS mode?'), 

Of course not.  Portable Python is a Windows product.  Your Kindle doesn't
run Windows.


>I've tried downloading ubuntu to my kindle and couldn't, 

Did you download the x86 version?  That will not work.  There are Ubuntu
distributions available for the Kindle Fire, but it's going to require
getting your hands dirty.  Google is your friend here.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Roberts
Pierre O'Dee  wrote:
>
>Guido went on to say that he's now working on a new language
>called Giddy-up-and-Go which will take the worst features of C++,
>Java, and French combined with elements of both PHP and Klingon
>syntax.

This would seem like the ideal programming language in which to implement
an open source version of the ill-fated Microsoft Bob project.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Switching from Apche to LiteSpeed

2013-04-01 Thread nagia . retsina
Τη Δευτέρα, 1 Απριλίου 2013 11:29:47 μ.μ. UTC+3, ο χρήστης John Gordon έγραψε:
> In <9a35850a-7fcb-4585-84ae-5e13cef91...@googlegroups.com> 
> =?ISO-8859-7?B?zd/q7/Igw+rxMzPq?=  writes:
> 
> 
> 
> > Just today i changed from HostGator to EZPZ, which means from Apache Web 
> > Server to LiteSpeed.
> 
> 
> 
> > Does anyone know why iam seeing what iam seeing at http://superhost.gr
> 
> 
> 
> > I see weird encoding although inside my python script i have:
> 
> 
> 
> > #!/usr/bin/python
> 
> > # -*- coding=utf-8 -*
> 
> 
> 
> I believe the syntax is to use a colon, not an equal sign.  i.e.:
> 
> 
> 
> # -*- coding: utf-8 -*-
> 
> 
> 
> Your example is also missing the final dash after the asterisk.
> 
> 
> 
> -- 
> 
> John Gordon   A is for Amy, who fell down the stairs
> 
> gor...@panix.com  B is for Basil, assaulted by bears
> 
> -- Edward Gorey, "The Gashlycrumb Tinies"

Thank you but even like you said i still see ncoding issues as seen in my 
webpage
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 3:45 PM, Tim Roberts  wrote:
> morphex  wrote:
>>
>>While we're on the subject, wouldn't it be nice to have some cap there so
>>that it isn't possible to more or less block the system with large
>>exponentiation?
>
> There IS a cap.  It's called the "MemoryError" exception.
>
> But, seriously, what would you have it do instead?

And If you want a lower cap than the one you currently have, check out
ulimit/rlimit - you can trigger MemoryError sooner.

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


Re: Switching from Apche to LiteSpeed

2013-04-01 Thread Steven D'Aprano
On Mon, 01 Apr 2013 20:29:47 +, John Gordon wrote:

> In <9a35850a-7fcb-4585-84ae-5e13cef91...@googlegroups.com>
> =?ISO-8859-7?B?zd/q7/Igw+rxMzPq?=  writes:
> 
>> Just today i changed from HostGator to EZPZ, which means from Apache
>> Web Server to LiteSpeed.
> 
>> Does anyone know why iam seeing what iam seeing at http://superhost.gr
> 
>> I see weird encoding although inside my python script i have:
> 
>> #!/usr/bin/python
>> # -*- coding=utf-8 -*
> 
> I believe the syntax is to use a colon, not an equal sign.  i.e.:
> 
> # -*- coding: utf-8 -*-
> 
> Your example is also missing the final dash after the asterisk.


I don't think that will make a difference. Encoding declaration lines are 
*very* flexible, and will match either a colon or equals sign. So long as 
it matches this regular expression, it will be understood:

coding[=:]\s*([-\w.]+)

http://docs.python.org/2/reference/lexical_analysis.html#encoding-declarations


However, it is important that the encoding being declared matches the 
actual encoding being used! For example, if you take a Latin-1 file, and 
declare that it is UTF-8, it won't magically turn the Latin-1 file into 
UTF-8. Instead you'll get bytes being decoded wrongly.



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