Python advice

2014-09-22 Thread ngangsia akumbo
I have learned python for some time now. I am developing apps using django. 

I need some advice.
I want to be able to write big programs using python. I have not been able to 
do that as of now. I need a way forward on what more free ebooks i can get mt 
hands on so i can accomplish my goals.

I need some advice. should i go on to learn other languages like java or c++ 
cos i want to be able to using all these knowledge for games, desktop, mobile 
and web.

i start learning java and i seem it is more real life. it looks real that 
python.

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


Re: Python advice

2014-09-22 Thread ngangsia akumbo
PRESENTLY I AM READING A BOOK MASTERING PYTHON ALGORITHMS. IT MAKES MUCH SENSE
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread vek . m1234
One thing I noticed with that code was the size of your function, and excessive 
comments. It reminds me of my bubble_sort.c program in school/college - 
everything plonked into 'main'.

Try writing it like this:

1. #!/usr/bin/python or #!/usr/bin/env python

The leading #! is read by the kernel when it has to start the interpreter 
(exec), so don't stick your comment in there.

2. Try to align the imports so they look pretty

3. Don't use whacking big functions and then stick endless explanatory comments
Use the function name as a comment instead - divide your program up into little 
tasks. Try to make the stuff generic - def url_extract(content, pattern): 

def extract_url

def extract_title

def tk_init

Use
#---
to demarcate sections, very common functions go into a utility-library,
not so common functions at the section at start of the file, and so on..

4. Don't skimp on the sys.exit() or def debug (which should be in your 
utilities lib)

5. Don't do :x = foo('.')
instead:
var_name = '..' # make it global
x = foo(var_name)

6. To build a string do:

param1 = xyz1 + xyz2
x = foo(param1)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python advice

2014-09-22 Thread vek . m1234
1. Python Essential Reference, Python Standard Library by Example/Dive into 
Python
2. C (K.N.King), C++(Eckel), Python, Make, GCC, Lex/Yacc/Bison, Some 
HTML/CSS/XML/Javascript/XLTS+Python

3. I don't like Java much - never tried it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 7:00 PM,   wrote:
> One thing I noticed with that code was the size of your function, and 
> excessive comments. It reminds me of my bubble_sort.c program in 
> school/college - everything plonked into 'main'.
>
> Try writing it like this:

I'd like to see justifications for some of the advice you're giving
here. Quite a bit of it I disagree with :)

> 1. #!/usr/bin/python or #!/usr/bin/env python
>
> The leading #! is read by the kernel when it has to start the interpreter 
> (exec), so don't stick your comment in there.

Very much optional. Even on Unix systems, it's not necessary unless
you want it to be executable.

> 2. Try to align the imports so they look pretty

You mean adding extra spaces? Not advised. Or something else?
Definitely needs more explanation (maybe an example) and justification
(why do it?).

> 3. Don't use whacking big functions and then stick endless explanatory 
> comments
> Use the function name as a comment instead - divide your program up into 
> little tasks. Try to make the stuff generic - def url_extract(content, 
> pattern):
>
> def extract_url
>
> def extract_title
>
> def tk_init
>
> Use
> #---
> to demarcate sections, very common functions go into a utility-library,
> not so common functions at the section at start of the file, and so on..

If functions are defined and then called from exactly one place,
there's no need to put them anywhere else. Just inline them. It's not
as if the indentation is getting out of hand here - getinfo() tops out
at just three tabs in, which is nothing. I've gone to seven a number
of times, and there's one particular piece of code I have that goes as
far as nine - though that's not something I'd recommend! Different
people will put the limit at different points, but three is never
going to be excessive. (Cue someone pointing out to me a situation in
which three really is excessive, but sure, that'll be a fun spin-off
thread.)

> 4. Don't skimp on the sys.exit() or def debug (which should be in your 
> utilities lib)

More explanation needed, please. What are you trying to do here? What
would be different?

> 5. Don't do :x = foo('.')
> instead:
> var_name = '..' # make it global
> x = foo(var_name)

Uhhh, why??!?

> 6. To build a string do:
>
> param1 = xyz1 + xyz2
> x = foo(param1)

Ditto. Why?!?

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


Re: pgs4a fails to build

2014-09-22 Thread Mark Lawrence

On 22/09/2014 03:00, aws Al-Aisafa wrote:

Yes I've followed and installed everything



Please provide some context when you reply and to whom you are replying, 
thank you.


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

Mark Lawrence

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


face detection

2014-09-22 Thread narayan naik
good evening sir,
I am doing my M.Tech project on face
detection,I am confused with the face detection algorithm,can you please
tell me the simple and best algorithm.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant

> class User(Inheritance from API):
> def __init__(self, ID):
> steamapi.core.APIConnection(api_key = KEY)
> super( " Inheritance SteamUser" (ID)) # creates the user using the
> API
> 
> 
> [...]
> 
> 
> So that in my code when I need to create a new user, I just call 'usr
> = User("XXX")' instead of calling 'usr =
> steamapi.user.SteamUser(76561197996416028)', is that possible?
[snip


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


How to not enable a user to close the root tkinter window

2014-09-22 Thread Nicholas Cannon
I have a project I am working on(https://github.com/nicodasiko/Article-Grab) 
which grabs info from the internet then displays it on the screen. It is a 
multithreaded program so as the function that retrieves the data from the 
internet there is also another function running in parallel which updates a ttk 
loading bar. Pretty simple multi threaded stuff. But I found out that the user 
can close the window whilst the threads are running which generates an error 
and is not healthy. Is there a way I can make the root tkinter window not close 
whilst the threads are running. I did this with the search bar and search 
button. Or can I safely stop the running threads and make them drop everything 
error free? Any help will be apreciated!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread vek . m1234
1. It's feedback not a mathematical proof.
2. I hope the OP tries what I suggested - it's all entirely optional.

@OP
I have no idea what that program does because it's well commented. You aren't 
using variable and function names to good effect and are resorting to excessive 
comments.

Additionally, I think you are mangling your display text but I'm not sure.
textDisplay.insert should be a function that you pass args to.

def spit_msg(text):
textDisplay.insert(text)

spit_msg("go away doo doo bird")

Any time you see repeated text in your program, wrap it in a single func and 
simplify.

try: 
def create_root_window():
 rather than letting all your funny parts dangle around naked.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to not enable a user to close the root tkinter window

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 9:43 PM, Nicholas Cannon
 wrote:
> Or can I safely stop the running threads and make them drop everything error 
> free?

This would be what I'd recommend. If someone wants to close your
program, s/he should be allowed to - imagine if internet traffic is
costly [1] and the query was done accidentally. So what you need is to
have the shutdown divided into three steps:

1) Close the window, or at least show visually that it's shutting down.
2) Send a signal to the worker threads
3) When the worker threads all shut down, terminate the program.

You can handle step 3 simply by ensuring that the threads aren't
marked as daemons. Python won't shut down until they're all gone. Step
1 is, I suspect, already happening. So all you need to do is message
the worker thread - and that can be done simply by setting a global
variable or something.

However, I'm not seeing any use of threads in your code. What thread
is being cut off? What's the error you're seeing?

ChrisA

[1] "costly" might not mean money, although it can. But imagine you're
on a slow connection and you can't afford to have other programs
lagging out something that's important.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread vek . m1234
https://github.com/Veek/Python/blob/master/IRC/Hexchat/fake_ctcp.py
that's not too bad as far as readability is concerned and it's bereft of all 
comments {:p
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 9:47 PM,   wrote:
> 1. It's feedback not a mathematical proof.
> 2. I hope the OP tries what I suggested - it's all entirely optional.

Doesn't change the fact that you need to justify your recommendations,
at least when they're not obvious. You're suggesting a number of
things which are definitely not the same as I'd recommend, and I can't
evaluate them because you haven't explained *why* you give that
advice.

> @OP
> I have no idea what that program does because it's well commented. You aren't 
> using variable and function names to good effect and are resorting to 
> excessive comments.

Comments are not bad. His variable names aren't nearly as bad as you
imply. I can read the code *just fine*. Either you're exaggerating, or
you're trolling, or you're extremely dim. I'm not sure which.

> Additionally, I think you are mangling your display text but I'm not sure.
> textDisplay.insert should be a function that you pass args to.
>
> def spit_msg(text):
> textDisplay.insert(text)
>
> spit_msg("go away doo doo bird")
>
> Any time you see repeated text in your program, wrap it in a single func and 
> simplify.

Not every one-liner needs to be a function. Not all repeated text
needs to be wrapped up. You can always add another level of
indirection, and it's frequently not necessary.

> try:
> def create_root_window():
>  rather than letting all your funny parts dangle around naked.

This seems incomplete. What's this try block for? What's the function
for? Will it be called from more than one place? If not, why wrap it
up?

Again, you need to explain *why* something needs to be changed.
Telling someone "do this, this, this, and this" is almost completely
useless, because it doesn't teach any better programming practices -
in fact, it may teach a black-box programming style that's good only
for novices (like saying "always put 'from __future__ import
print_function' at the top of your Python files", which might be a
perfectly good thing to do, but at some point you need to explain
why).

Also, you're posting on a mailing list and newsgroup. Please include
context in your posts so we know what you're talking about.

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


Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
- Original Message -
> From: "Jean-Michel Pichavant" 
> To: "Juan Christian" 
> Cc: "Python" 
> Sent: Monday, 22 September, 2014 1:37:41 PM
> Subject: Re: Class Inheritance from different module
> 
> 
> > class User(Inheritance from API):
> > def __init__(self, ID):
> > steamapi.core.APIConnection(api_key = KEY)
> > super( " Inheritance SteamUser" (ID)) # creates the user using the
> > API
> > 
> > 
> > [...]
> > 
> > 
> > So that in my code when I need to create a new user, I just call
> > 'usr
> > = User("XXX")' instead of calling 'usr =
> > steamapi.user.SteamUser(76561197996416028)', is that possible?
> [snip

Sorry, sent the message by mistake.

Anyway if you just want a nice way to create an instance, you may simply write

import steamapi.user.SteamUser as User

usr = User('whatever')

However you don't create an APIConnection when creating a user, it does not 
make much sense, you only need one API connection per session and it will be 
shared by all the User objects.

# Note ApiConnection is a singleton, and you only need to execute this once, in 
you app/script initialization for instance.
api = APIConnection(api_key='dlkfnsdlfn')

# query the database
user1 = User('user1')
user2 = User('user2')

Cheers,

JM


NB: I assumed you were using https://github.com/smiley/steamapi
NB2 : because APIConnection is a singleton, your original code probably works 
just fine, I'm just not a big fan of breaking to python module design


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 10:00 PM,   wrote:
> https://github.com/Veek/Python/blob/master/IRC/Hexchat/fake_ctcp.py
> that's not too bad as far as readability is concerned and it's bereft of all 
> comments {:p

Sure, I can work out what it's doing without comments. Doesn't mean
comments are bad, though. Also, without comments, I have no idea *why*
it's doing what it does. For instance, this:

> def debug(msg):
> hexchat.prnt('{}'.format(msg))

Why not just do this:
debug = hexchat.prnt

Or, better still, just use hexchat.prnt() everywhere, instead of
having a local name? (You happily use hexchat.* in other places.) Is
it meant to be monkey-patched externally? Is it meant to be a
one-place edit? What's the purpose of this one-line function?

> date = str(date_s) + ' ' + str(hour) + ':' + str(min) + ':' + str(sec)

You use .format() in places where it's completely unnecessary, but
eschew it when it would make your code more readable.

date = "%s %s:%s:%s" % (date_s, hour, min, sec)
date = "{} {}:{}:{}".format(date_s, hour, min, sec)

So, comments would definitely help. In some cases, would help a lot.

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Larry Martell
On Mon, Sep 22, 2014 at 8:23 AM, Chris Angelico  wrote:
> So, comments would definitely help. In some cases, would help a lot.

This is me:

http://xkcd.com/1421/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Nicholas Cannon
Ok I'm confused. Do I need to do better comments? I know the text is not that 
great but that is my next obstacle I am going to tackle. I mostly need to know 
where I am going wrong such as what is expectable readable code and what is not 
and how to fix this. This is good feedback thanks to all of you guys. All I 
want to do is learn and become better and neater!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Nicholas Cannon
Also I have just been coding for about and hour and a half and added a lot more 
code to it but it is not fully finished yet so it is not on github yet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 11:02 PM, Larry Martell  wrote:
> On Mon, Sep 22, 2014 at 8:23 AM, Chris Angelico  wrote:
>> So, comments would definitely help. In some cases, would help a lot.
>
> This is me:
>
> http://xkcd.com/1421/

Also me. I have apologized to my future selves on a number of
occasions. And of course, very VERY frequently, I have answered my
future selves' questions. That, I think, is the primary purpose of
code comments. It's a kind of limited-range time travel: I can travel
back in time, ask myself a question, and get an answer.

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 11:17 PM, Nicholas Cannon
 wrote:
> Ok I'm confused. Do I need to do better comments? I know the text is not that 
> great but that is my next obstacle I am going to tackle. I mostly need to 
> know where I am going wrong such as what is expectable readable code and what 
> is not and how to fix this. This is good feedback thanks to all of you guys. 
> All I want to do is learn and become better and neater!
>

Your comments aren't terrible. Just imagine yourself reading this code
six months from now, having not touched it in between, and imagine all
the questions you'd ask yourself. Then answer them. Conversely, if
something would be patently obvious to your future self, don't bother
commenting it.

Have a read of some of the tips here. You may find them helpful.

http://www.catb.org/esr/faqs/hacker-howto.html

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread vek . m1234
@Chris, Hi, I don't like your style of posting - please kill file me.

@Everybody else - I don't like Chris and his style of posting (overuse of the 
'troll' word and perceived aggression). I shall be ignoring him for a year 
(barring an emergency). Good communication demands that I announce this. Please 
don't misconstrue this as rudeness on my part. If you feel that he is asking 
something of pertinence, feel free to include it in your posts for a reply.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread C Smith
I wouldn't take it personally, just defend your position. I think that
is what he is looking for. We are all adults here (maybe?). You guys
should be able to work it out. A tangential skill to programming is
being able to give and take criticism well, even if you think it
crosses the line.

On Mon, Sep 22, 2014 at 6:35 AM,   wrote:
> @Chris, Hi, I don't like your style of posting - please kill file me.
>
> @Everybody else - I don't like Chris and his style of posting (overuse of the 
> 'troll' word and perceived aggression). I shall be ignoring him for a year 
> (barring an emergency). Good communication demands that I announce this. 
> Please don't misconstrue this as rudeness on my part. If you feel that he is 
> asking something of pertinence, feel free to include it in your posts for a 
> reply.
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Mon, Sep 22, 2014 at 11:48 PM, C Smith  wrote:
> I wouldn't take it personally, just defend your position. I think that
> is what he is looking for. We are all adults here (maybe?). You guys
> should be able to work it out. A tangential skill to programming is
> being able to give and take criticism well, even if you think it
> crosses the line.

Precisely. Asking for justification isn't meant to imply that there is
none. But it's like back in my high school maths lessons: if you don't
show your working, there's no way to discuss the details, and if the
conclusion is wrong (or in this case, is disagreed with), you can't do
anything with it. With the intermediate steps given, we can discuss,
explain, and maybe find that we mostly agree.

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


[RELEASE] Python 3.4.2rc1 is now available

2014-09-22 Thread Larry Hastings



On behalf of the Python development community and the Python 3.4 release 
team, I'm chuffed to announce the availability of Python 3.4.2rc1. 
Python 3.4.2 has many bugfixes and other small improvements over 3.4.1.  
One new feature for Mac OS X users: the OS X installers are now 
distributed as signed installer package files compatible with the OS X 
Gatekeeper security feature.


You can download it here:

   https://www.python.org/download/releases/3.4.2


Be seeing you,


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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant
- Original Message -
> From: "Chris Angelico" 
> Cc: python-list@python.org
> Sent: Saturday, 20 September, 2014 4:58:44 PM
> Subject: Re: Love to get some feedback on my first python app!!!
[snip]
> 
> #search API
> rawData =
> 
> urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='+encodedQuery).read()
> #loads data from API into json
> jsonData = json.loads(rawData)
> #extracts the results from API
> searchResults = jsonData['responseData']['results']
> 
> The more normal way to write these would be in present tense, in a
> more imperative style: "Fix some bugs", "Load data", "Extract
> results". (Although these comments are actually quite redundant - all
> they do is tell you what the single next line of code does.) 

I used to belong to the cult "don't repeat yourself" in the comments, being 
angry against people who thought I couldn't understand by myself the simplest 
line of code.

But I changed my mind. I've read some code comments over the years and best 
ones (imo) where those which where actually repeating themselves.
Golden rules of comments:

# state what you plan to do
doIt()

For instance:

cells = ['a', 'b' 'c']
# print the first cell
print cell[1]

A bug that is easily spotted thanks to the comment. It's all about 
implementation versus intentions. Also note that comment should be written for 
the future self,  and most importantly, for the current others.

JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Joel Goldstick
On Mon, Sep 22, 2014 at 10:32 AM, Jean-Michel Pichavant
 wrote:
> - Original Message -
>> From: "Chris Angelico" 
>> Cc: python-list@python.org
>> Sent: Saturday, 20 September, 2014 4:58:44 PM
>> Subject: Re: Love to get some feedback on my first python app!!!
> [snip]
>>
>> #search API
>> rawData =
>> 
>> urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='+encodedQuery).read()
>> #loads data from API into json
>> jsonData = json.loads(rawData)
>> #extracts the results from API
>> searchResults = jsonData['responseData']['results']
>>
>> The more normal way to write these would be in present tense, in a
>> more imperative style: "Fix some bugs", "Load data", "Extract
>> results". (Although these comments are actually quite redundant - all
>> they do is tell you what the single next line of code does.)
>
> I used to belong to the cult "don't repeat yourself" in the comments, being 
> angry against people who thought I couldn't understand by myself the simplest 
> line of code.
>
> But I changed my mind. I've read some code comments over the years and best 
> ones (imo) where those which where actually repeating themselves.
> Golden rules of comments:
>
> # state what you plan to do
> doIt()
>
> For instance:
>
> cells = ['a', 'b' 'c']
> # print the first cell
> print cell[1]
>
> A bug that is easily spotted thanks to the comment. It's all about 
> implementation versus intentions. Also note that comment should be written 
> for the future self,  and most importantly, for the current others.
>
> JM
>
Docstrings -- look them up.  Then you can run pydocs (and help!) on
your code and see excellent documentation

I would break up the big function into a few smaller ones that are
easier to describe.  Unless there is something very weird in the code,
I don't think #inline comments saying the obvious are useful, but a
summary at the top of the module, function, class, etc. is important

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 12:32 AM, Jean-Michel Pichavant
 wrote:
> For instance:
>
> cells = ['a', 'b' 'c']
> # print the first cell
> print cell[1]
>
> A bug that is easily spotted thanks to the comment. It's all about 
> implementation versus intentions. Also note that comment should be written 
> for the future self,  and most importantly, for the current others.

I do see your point, but there's a serious problem here of code edits.
It's really easy to zip through and find all occurrences of some name
and change them - and miss the one in the comment. In this particular
case, I'm not actually sure where the bug is: is it in the first line
(should be "cell = ...") or the third ("print cells[1]")? Either way,
the comment doesn't make it any clearer, because the plural rule in
English doesn't always match naming of variables. Also, it's common in
English to count from 1, but in code to count from 0; so there's
another bug (and this might be the one you thought easily spotted) -
it should either be "cell[0]" in the third line, or "print the 1th
cell" in the second.

(Plus, there's a comma omitted. That list has two elements, but I
think it's meant to have three. However, I'm guessing that's a
transcription error, or a construction-in-email error, and nothing to
do with what you're saying.)

Now, compare this similar code:

cells = ['Chris Angelico', 'ros...@gmail.com', 142857]
# print the email address
print(cells[2])

This says *why* it's doing what it does - what the meaning of the
index is. And it, too, has a clearly visible bug, because when it
prints out an integer, the comment makes it obvious that it's done the
wrong thing. This is, IMO, much more useful. If the code gets edited
(maybe the name used to be in two fields for First Name and Last Name,
and then someone realized how bad an idea that is - but forgot to
update the index), the original intention is visible; if it just says
"print out cell #2", it's not so helpful.

So basically, don't *purely* repeat yourself, but give some info
that's a level behind the code.

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


Re: [python-committers] [RELEASE] Python 3.4.2rc1 is now available

2014-09-22 Thread Victor Stinner
Someone broke test_pydoc. Example:
http://buildbot.python.org/all/builders/AMD64%20FreeBSD%2010.0%203.4/builds/481/steps/test/logs/stdio

Victor

2014-09-22 16:15 GMT+02:00 Larry Hastings :
>
>
> On behalf of the Python development community and the Python 3.4 release
> team, I'm chuffed to announce the availability of Python 3.4.2rc1.   Python
> 3.4.2 has many bugfixes and other small improvements over 3.4.1.  One new
> feature for Mac OS X users: the OS X installers are now distributed as
> signed installer package files compatible with the OS X Gatekeeper security
> feature.
>
> You can download it here:
>
> https://www.python.org/download/releases/3.4.2
>
>
> Be seeing you,
>
>
> /arry
>
> ___
> python-committers mailing list
> python-committ...@python.org
> https://mail.python.org/mailman/listinfo/python-committers
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread vek . m1234
@CSmith
Hi, I'm sorry, I wish I could acquiesce but I think it's better for me to stay 
clear. There's criticism, and there's name calling ('dim' 'troll').

Reiterating what I said earlier, if the OP wants clarification he can ask for 
it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread alister
On Mon, 22 Sep 2014 16:32:27 +0200, Jean-Michel Pichavant wrote:

> - Original Message -
>> From: "Chris Angelico" 
>> Cc: python-list@python.org Sent: Saturday, 20 September, 2014 4:58:44
>> PM Subject: Re: Love to get some feedback on my first python app!!!
> [snip]
>> 
>> #search API rawData =
>> urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/
web?v=1.0&q='+encodedQuery).read()
>> #loads data from API into json jsonData = json.loads(rawData)
>> #extracts the results from API searchResults =
>> jsonData['responseData']['results']
>> 
>> The more normal way to write these would be in present tense, in a more
>> imperative style: "Fix some bugs", "Load data", "Extract results".
>> (Although these comments are actually quite redundant - all they do is
>> tell you what the single next line of code does.)
> 
> I used to belong to the cult "don't repeat yourself" in the comments,
> being angry against people who thought I couldn't understand by myself
> the simplest line of code.
> 
> But I changed my mind. I've read some code comments over the years and
> best ones (imo) where those which where actually repeating themselves.
> Golden rules of comments:
> 
> # state what you plan to do doIt()
> 
> For instance:
> 
> cells = ['a', 'b' 'c']
> # print the first cell print cell[1]

That is not too bad, "Print Customer name from cell 1" may be better as 
it would stick out if the data structure changed

what is meant by don't state the obvious in comments is stating something 
like "Increment x" without explaining why.

-- 
"It is hard to overstate the debt that we owe to men and women of genius."
-- Robert G. Ingersoll
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant


- Original Message -
> From: "Chris Angelico" 
> Cc: python-list@python.org
> Sent: Monday, 22 September, 2014 4:50:15 PM
> Subject: Re: Love to get some feedback on my first python app!!!
> 
> On Tue, Sep 23, 2014 at 12:32 AM, Jean-Michel Pichavant
>  wrote:
> > For instance:
> >
> > cells = ['a', 'b' 'c']
> > # print the first cell
> > print cell[1]
> >
> > A bug that is easily spotted thanks to the comment. It's all about
> > implementation versus intentions. Also note that comment should be
> > written for the future self,  and most importantly, for the
> > current others.
> 
> I do see your point, but there's a serious problem here of code
> edits.
> It's really easy to zip through and find all occurrences of some name
> and change them - and miss the one in the comment. In this particular
> case, I'm not actually sure where the bug is: is it in the first line
> (should be "cell = ...") or the third ("print cells[1]")? Either way,
> the comment doesn't make it any clearer, because the plural rule in
> English doesn't always match naming of variables. Also, it's common
> in
> English to count from 1, but in code to count from 0; so there's
> another bug (and this might be the one you thought easily spotted) -
> it should either be "cell[0]" in the third line, or "print the 1th
> cell" in the second.
> 
> (Plus, there's a comma omitted. That list has two elements, but I
> think it's meant to have three. However, I'm guessing that's a
> transcription error, or a construction-in-email error, and nothing to
> do with what you're saying.)
> 
> Now, compare this similar code:
> 
> cells = ['Chris Angelico', 'ros...@gmail.com', 142857]
> # print the email address
> print(cells[2])
> 
> This says *why* it's doing what it does - what the meaning of the
> index is. And it, too, has a clearly visible bug, because when it
> prints out an integer, the comment makes it obvious that it's done
> the
> wrong thing. This is, IMO, much more useful. If the code gets edited
> (maybe the name used to be in two fields for First Name and Last
> Name,
> and then someone realized how bad an idea that is - but forgot to
> update the index), the original intention is visible; if it just says
> "print out cell #2", it's not so helpful.
> 
> So basically, don't *purely* repeat yourself, but give some info
> that's a level behind the code.
> 
> ChrisA

Damn you didn't fall into my trap :D.
The code I posted had many bugs but one could not be fixed without the comment. 
Or at least there's an obvious discrepancy between the comment and the code 
that should catch the reader's attention.

Anyway it's seems we agree anyway because your example perfectly illustrate 
what I was trying to demonstrate:
print(cells[2]) is very easy to understand, most of people would say 'no need 
of any comment'. I think it does require a comment.

I find myself writing a comment every 3 or 4 line of code, at least, for what 
I've read, that's way too much.

JM










-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 1:52 AM, Jean-Michel Pichavant
 wrote:
> The code I posted had many bugs but one could not be fixed without the 
> comment. Or at least there's an obvious discrepancy between the comment and 
> the code that should catch the reader's attention.
>

The obvious discrepancy, sadly, doesn't tell you which one is right.
It's like the old days of FAT file systems - DOS would maintain two
copies of the eponymous File Allocation Table, but in the event of
corruption, it had no way of knowing which was to be trusted. (And I'm
not sure anything would ever actually notice differences, other than
an explicit CHKDSK.) When you have an intention comment, rather than
simply replicating the functionality in human-readable form, you can
more easily check that the intention matches the rest of the design.

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Mark Lawrence

On 22/09/2014 12:47, vek.m1...@gmail.com wrote:

1. It's feedback not a mathematical proof.


What is?


2. I hope the OP tries what I suggested - it's all entirely optional.


Which is?



@OP
I have no idea what that program does because it's well commented. You aren't 
using variable and function names to good effect and are resorting to excessive 
comments.

Additionally, I think you are mangling your display text but I'm not sure.
textDisplay.insert should be a function that you pass args to.

def spit_msg(text):
 textDisplay.insert(text)

spit_msg("go away doo doo bird")

Any time you see repeated text in your program, wrap it in a single func and 
simplify.

try:
def create_root_window():
  rather than letting all your funny parts dangle around naked.



Google groups rides again?

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

Mark Lawrence

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


Re: face detection

2014-09-22 Thread Denis McMahon
On Mon, 22 Sep 2014 15:29:58 +0530, narayan naik wrote:

> good evening sir,
> I am doing my M.Tech project on face
> detection,I am confused with the face detection algorithm,can you please
> tell me the simple and best algorithm.

http://www.lmgtfy.com/?q=best+face+detection+algorithm+python

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 2:10 AM, Mark Lawrence  wrote:
> Google groups rides again?

Yeah. And now someone from Google Groups has killfiled me. So it's up
to you to request/recommend alternatives, s/he won't see me saying so.

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Mark Lawrence

On 22/09/2014 14:35, vek.m1...@gmail.com wrote:

@Chris, Hi, I don't like your style of posting - please kill file me.

@Everybody else - I don't like Chris and his style of posting (overuse of the 
'troll' word and perceived aggression). I shall be ignoring him for a year 
(barring an emergency). Good communication demands that I announce this. Please 
don't misconstrue this as rudeness on my part. If you feel that he is asking 
something of pertinence, feel free to include it in your posts for a reply.



Laughable as you never give any context.  Please equip yourself with a 
decent tool, there are plenty to choose from.


And ignore Chris at your peril, he knows a fair bit about Python.  Sure 
he gets things wrong, but the only person who never gets things wrong is 
the person who never does anything.


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

Mark Lawrence

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Mark Lawrence

On 22/09/2014 14:48, C Smith wrote:

I wouldn't take it personally, just defend your position. I think that
is what he is looking for. We are all adults here (maybe?). You guys
should be able to work it out. A tangential skill to programming is
being able to give and take criticism well, even if you think it
crosses the line.

On Mon, Sep 22, 2014 at 6:35 AM,   wrote:

@Chris, Hi, I don't like your style of posting - please kill file me.

@Everybody else - I don't like Chris and his style of posting (overuse of the 
'troll' word and perceived aggression). I shall be ignoring him for a year 
(barring an emergency). Good communication demands that I announce this. Please 
don't misconstrue this as rudeness on my part. If you feel that he is asking 
something of pertinence, feel free to include it in your posts for a reply.
--
https://mail.python.org/mailman/listinfo/python-list


Hells bells if it's not googlegroups it's top posting.  What did I do in 
a past life to deserve this?


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

Mark Lawrence

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 2:17 AM, Mark Lawrence  wrote:
> And ignore Chris at your peril, he knows a fair bit about Python.  Sure he
> gets things wrong, but the only person who never gets things wrong is the
> person who never does anything.

Thanks :)

I don't mind being wrong, or being told I'm wrong. Those are some of
the best threads we've ever had - lengthy debates by intelligent
people who start out with different views, figuring out exactly what
the differences are and why there are those differences. Those are the
threads that differentiate c.l.p/python-list from Facebook - there's
solid content, serious discussion, and stuff that's worth going back
to.

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Mark Lawrence

On 22/09/2014 13:00, vek.m1...@gmail.com wrote:

https://github.com/Veek/Python/blob/master/IRC/Hexchat/fake_ctcp.py
that's not too bad as far as readability is concerned and it's bereft of all 
comments {:p



Definitely googlegroups rides again.

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

Mark Lawrence

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Mark Lawrence

On 22/09/2014 14:17, Nicholas Cannon wrote:

Ok I'm confused. Do I need to do better comments? I know the text is not that 
great but that is my next obstacle I am going to tackle. I mostly need to know 
where I am going wrong such as what is expectable readable code and what is not 
and how to fix this. This is good feedback thanks to all of you guys. All I 
want to do is learn and become better and neater!



So am I.  To whom are you replying and about what?  I'm not spending my 
time trying to find out just because you can't be bothered to use a 
decent tool when posting here.


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

Mark Lawrence

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


Comparison

2014-09-22 Thread LJ
Hi All,

Quick question here. In the code I am working on I am apparently doing a lot of 
dictionary lookups and those are taking a lot of time. 
I looked at the possibility of changing the structure and I found about the 
numpy structured arrays.
The concrete question is: what would be the difference between using one or the 
other in terms of performance? meaning looping and performing checks an 
operations on them?

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


Re: Comparison

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 2:57 AM, LJ  wrote:
> Quick question here. In the code I am working on I am apparently doing a lot 
> of dictionary lookups and those are taking a lot of time.
> I looked at the possibility of changing the structure and I found about the 
> numpy structured arrays.
> The concrete question is: what would be the difference between using one or 
> the other in terms of performance? meaning looping and performing checks an 
> operations on them?

The lookups themselves almost certainly aren't actually taking the
time, unless you have some kind of crazy hash collision happening,
which is so statistically unlikely that it would have to have come
from malice. What's the code doing? What are you trying to accomplish?
It's much more likely that you have an algorithmic flaw than a data
type inefficiency.

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


Re: Comparison

2014-09-22 Thread LJ
On Monday, September 22, 2014 1:12:23 PM UTC-4, Chris Angelico wrote:
> On Tue, Sep 23, 2014 at 2:57 AM, LJ  wrote:
> 
> > Quick question here. In the code I am working on I am apparently doing a 
> > lot of dictionary lookups and those are taking a lot of time.
> 
> > I looked at the possibility of changing the structure and I found about the 
> > numpy structured arrays.
> 
> > The concrete question is: what would be the difference between using one or 
> > the other in terms of performance? meaning looping and performing checks an 
> > operations on them?
> 
> 
> 
> The lookups themselves almost certainly aren't actually taking the
> 
> time, unless you have some kind of crazy hash collision happening,
> 
> which is so statistically unlikely that it would have to have come
> 
> from malice. What's the code doing? What are you trying to accomplish?
> 
> It's much more likely that you have an algorithmic flaw than a data
> 
> type inefficiency.
> 
> 
> 
> ChrisA



Thank you for your reply.

Basically what is happening is the following:

I have a network in which the nodes are defined as dictionaries using the 
NetworkX package. Inside each node (each dictionary) I defined a dictionary of 
dictionaries holding attributes corresponding to different ways in which the 
node can be reached (this dictionaries I refer to as labels). 
At some point in my algorithm I am looping through some subset of nodes and 
through the labels in each node and I perform some "joining" checks with the 
labels of each node in another subset of nodes. To clarify I check for a 
feasibility condition in a pairwise manner for every label in one node and 
every label of another. This nested loop is taking time.
I wonder if the fact of defining the labels using numpy instead of dictionaries 
could imply a faster way to perform this loop.

I hope I was clear.

Thanks.

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


Re: Comparison

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 3:38 AM, LJ  wrote:
> At some point in my algorithm I am looping through some subset of nodes and 
> through the labels in each node and I perform some "joining" checks with the 
> labels of each node in another subset of nodes. To clarify I check for a 
> feasibility condition in a pairwise manner for every label in one node and 
> every label of another. This nested loop is taking time.
>

Okay, that's where the issue is - you're doing a cross-match, that's
going to be comparing every label against every other.

You might be able to cache some references to part-way into the tree,
depending on how your code is written, but ultimately, you still need
to do all of those checks.

What's the definition of feasibility? Can you optimize that? Maybe
there's a way to do a rough check that cuts down the number you have
to do the exact check on.

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


Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Irmen de Jong
Hi,

I've developed Pyrolite (https://github.com/irmen/Pyrolite), a lightweight 
client
library for Java and .NET to gain access to Python servers running Pyro. As 
such it also
contains a complete pickle and unpickle implementation in these languages.

Quite recently I got a pull request to fix a big/little-endianness decoding 
issue
regarding machine floats and doubles in pickled arrays.

It was a mistake on my part but it got me thinking: the unit tests of my 
library should
ideally be run on both little- and big-endian machines, because some of the 
code depends
on this.

I've only got access to little endian systems myself. So basically I'm looking 
for some
tips here, for instance can Travis-ci.org perhaps help out? Or can someone here 
with
access to a big endian system help me out with running the Java and .NET 
(Microsoft or
Mono) unit test suite of my project on that system? (just a one time request, 
to verify
the current version).


Irmen de Jong

PS the reason why I'm posting a Java or .NET related issue here is because the 
core
protocol my library handles is a Python invented one ;)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 3:47 AM, Irmen de Jong  wrote:
> I've developed Pyrolite (https://github.com/irmen/Pyrolite), a lightweight 
> client
> library for Java and .NET to gain access to Python servers running Pyro. As 
> such it also
> contains a complete pickle and unpickle implementation in these languages.

Does this imply that you send pickle data across the internet and
unpickle it? Isn't that rather dangerous?

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


Re:Python advice

2014-09-22 Thread Dave Angel
ngangsia akumbo  Wrote in message:
> I have learned python for some time now. I am developing apps using django. 
> 
> I need some advice.
> I want to be able to write big programs using python. I have not been able to 
> do that as of now.

Define'big'.  I could write a 25 line Python program that
 generates gigabytes of useful data. Or I could write 100,000
 lines of assembler that could have been done in 1000 lines of
 some other language. When you say you haven't been able to do
 (something), just what has been stopping you? 

> I need a way forward on what more free ebooks i can get mt hands on so i can 
> accomplish my goals.
> 
> I need some advice. should i go on to learn other languages like java or c++ 
> cos i want to be able to using all these knowledge for games, desktop, mobile 
> and web.

You certainly should learn other languages.  I used about 35
 during my career.  But until you've mastered one, c++ and Java
 will probably be more confusing than helpful.  There are others
 you probably need first,  such as html, css, regex. And other
 skills,  such as a debugger,  profiler,  customizable editor.
 

> 
> i start learning java and i seem it is more real life. 

Do you mean because it makes you work harder? I've used both, 
 though not on the same project.  And java isn't the tool I'd
 reach for, for most purposes. 

> it looks real that python.

This sentence isn't.  Perhaps you intended a comma after 'real',
 or some more words at the end.


-- 
DaveA

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Kaynor
On Mon, Sep 22, 2014 at 8:52 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:

> Anyway it's seems we agree anyway because your example perfectly
> illustrate what I was trying to demonstrate:
> print(cells[2]) is very easy to understand, most of people would say 'no
> need of any comment'. I think it does require a comment.
>

But the thing that requires the comment is the "2", not the "print" or the
"cells". And that comes to a more common issue: any number other than 0 or
1 in code most likely needs a comment (that comment could be merely a
variable name). Values of 0 or 1 may need a comment, but there are plenty
of cases where they are used quite clearly - its much less likely that
other numbers have obvious meaning.

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


Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Irmen de Jong
On 22-9-2014 19:53, Chris Angelico wrote:
> On Tue, Sep 23, 2014 at 3:47 AM, Irmen de Jong  wrote:
>> I've developed Pyrolite (https://github.com/irmen/Pyrolite), a lightweight 
>> client
>> library for Java and .NET to gain access to Python servers running Pyro. As 
>> such it also
>> contains a complete pickle and unpickle implementation in these languages.
> 
> Does this imply that you send pickle data across the internet and
> unpickle it? Isn't that rather dangerous?
> 
> ChrisA


Yes it is, good to point this out.

This is why Pyro has been using a different (and safe) serializer by default 
for a while
now. You have to plow through the usual security warnings in the docs and make a
conscious effort in your code to enable the pickle serializer if you really 
want/need it.

Pyrolite also contains a Java and .NET version of that safe serializer so you 
should not
be using pickle at all when dealing with Pyro, but its implementation is there. 
And the
pickle code can be used independently.


Irmen

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 4:24 AM, Chris Kaynor  wrote:
> On Mon, Sep 22, 2014 at 8:52 AM, Jean-Michel Pichavant
>  wrote:
>>
>> Anyway it's seems we agree anyway because your example perfectly
>> illustrate what I was trying to demonstrate:
>> print(cells[2]) is very easy to understand, most of people would say 'no
>> need of any comment'. I think it does require a comment.
>
>
> But the thing that requires the comment is the "2", not the "print" or the
> "cells". And that comes to a more common issue: any number other than 0 or 1
> in code most likely needs a comment (that comment could be merely a variable
> name). Values of 0 or 1 may need a comment, but there are plenty of cases
> where they are used quite clearly - its much less likely that other numbers
> have obvious meaning.

Or in this case, replacing the list with a namedtuple is probably more useful.

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


Re: Pyrolite, lightweight pickle and pyro client library, seeking a bit of testing help

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 4:23 AM, Irmen de Jong  wrote:
> This is why Pyro has been using a different (and safe) serializer by default 
> for a while
> now. You have to plow through the usual security warnings in the docs and 
> make a
> conscious effort in your code to enable the pickle serializer if you really 
> want/need it.

Is the safe serializer affected by byte order? If not, you could just
mark this off as a known bug, and say "if anyone has a big-endian
system to test this on, please help out". It would be another
incentive to use the safe serializer rather than pickle. And it'd save
you a lot of trouble. :)

I would have offered one of my systems for the test, except ...
they're all little-endian. I'm all PC-based hardware here (mainly
Linux running on Intel CPUs, though there are some variations).

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


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant
 Original Message -
> From: "Chris Angelico" 
> Cc: python-list@python.org
> Sent: Monday, 22 September, 2014 6:04:43 PM
> Subject: Re: Love to get some feedback on my first python app!!!
> 
> On Tue, Sep 23, 2014 at 1:52 AM, Jean-Michel Pichavant
>  wrote:
> > The code I posted had many bugs but one could not be fixed without
> > the comment. Or at least there's an obvious discrepancy between
> > the comment and the code that should catch the reader's attention.
> >
> 
> The obvious discrepancy, sadly, doesn't tell you which one is right.
[snip]
> 
> ChrisA

You're right but that's fine and the comment's still doing its job.
Either the comment is wrong, or the code is. It doesn't really matter which 
one, It needs to be investigated and fixed.

Otherwise you could say that writing specifications is pointless since 
specifications can be wrong and when a problem occur you need to figure out if 
either the code or the specification is responsible.

Like a CRC check, sometimes the payload is correct and the error is on the CRC, 
it's still damn useful.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: face detection

2014-09-22 Thread Gary Herron

On 09/22/2014 02:59 AM, narayan naik wrote:

good evening sir,
I am doing my M.Tech project on face 
detection,I am confused with the face detection algorithm,can you 
please tell me the simple and best algorithm.



No, sorry, but this newsgroup is about Python (a programming language).  
I'm not sure where you would find information about face detection, but 
I'm sure you could find a better forum with a little searching.


Gary Herron


--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


Re: Python advice

2014-09-22 Thread Chris Kaynor
On Mon, Sep 22, 2014 at 11:03 AM, Dave Angel  wrote:

> > I need a way forward on what more free ebooks i can get mt hands on so i
> can accomplish my goals.
> >
> > I need some advice. should i go on to learn other languages like java or
> c++ cos i want to be able to using all these knowledge for games, desktop,
> mobile and web.
>
> You certainly should learn other languages.  I used about 35
>  during my career.  But until you've mastered one, c++ and Java
>  will probably be more confusing than helpful.  There are others
>  you probably need first,  such as html, css, regex. And other
>  skills,  such as a debugger,  profiler,  customizable editor.


A lot of what you should learn will depend on what you want to do.

As a rule-of-thumb I'd recommend sticking to one or two high-level
languages until you are reasonably comfortable with them, then possibly
branching to other languages. As you've already started with Python, I'd
continue on it for a while. Possibly throw in Javascript/HTML/CSS for
web-development - for server-side code you could look in the to various
Python web frameworks, or learn PHP for those.

Once you are comfortable with at least one of those, you can consider
branching off into other languages as your projects need.

A few languages and their major strengths:

   - Python is pretty good base-line language. It is really good as a glue
   language to piece together other components, or for IO-bound or user-bound
   code, but will not preform well enough for many other applications such as
   games. It is good for short parts of games, but a full next-gen engine
   would be much too slow if written in pure Python, however Civilization 5
   uses Python as its scripting language. There are also libraries available
   that can provide enough performance to do basic games in Python.


   - C# is another good base-line language, although its much more limited
   to Windows (there are ways to run it on Mac and Linux, but not as easily).
   The main benefit it has is that, if you have Visual Studio, you get a nice
   UI designer built-in. Overall, this is a decent option for Windows-only GUI
   applications, and can be expanded with other libraries to other platforms,
   including many mobile platforms. Some web-servers can also run it as a
   server-side language.


   - Javascript is basically a necessity for web-based applications, as it
   is the only language that is commonly runnable across all browsers. There
   are, however, compilers that can (with some success) convert other
   languages to Javascript. (note: Javascript runs in the browser, primarily)


   - PHP is another commonly used web language, and is widely supported by
   servers. Anymore, there are also good Python libraries available for
   server-side webpages, although whether you can use them will depend on the
   server you are using. For some of the free servers, even PHP may not be
   supported, and you will only be able to do static sites (no server-side
   code).


   - C/C++ are both low level, and therefore generally harder to learn but
   provides much better performance than many other languages. I'd recommend
   putting these off until you are more comfortable with other, higher-level
   languages.


   - LUA is a commonly used scripting language for games. You'll find many
   engines have LUA support, as it tends to be very light-weight. I'd only
   recommend LUA if you want to program in one of those engines. World of
   Warcraft is one game I know of that has public support for LUA when making
   UI mods.


   - Objective-C is one of the main languages used for IOS (Apple)
   development.


   - Java is a commonly used language for Andoid development.

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


Re: program to generate data helpful in finding duplicate large files

2014-09-22 Thread random832
On Thu, Sep 18, 2014, at 14:45, Chris Kaynor wrote:
> Additionally, you may want to specify binary mode by using
> open(file_path,
> 'rb') to ensure platform-independence ('r' uses Universal newlines, which
> means on Windows, Python will convert "\r\n" to "\n" while reading the
> file). Additionally, some platforms will treat binary files differently.

Does 'r' not use universal newlines on unix? If not, why not? The only
purpose seems to be to allow people to write bad programs and have them
work on unix. It makes even less sense in python 3 where opening a file
in text mode results in a TextIOWrapper with utf-8 encoding, and
therefore can't be used on arbitrary binary files.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python advice

2014-09-22 Thread Ian Kelly
On Mon, Sep 22, 2014 at 1:00 PM, Chris Kaynor  wrote:
> Python is pretty good base-line language. It is really good as a glue
> language to piece together other components, or for IO-bound or user-bound
> code, but will not preform well enough for many other applications such as
> games. It is good for short parts of games, but a full next-gen engine would
> be much too slow if written in pure Python, however Civilization 5 uses
> Python as its scripting language. There are also libraries available that
> can provide enough performance to do basic games in Python.

Correction: Civilization 4 used Python for scripting. For Civilization
5 they switched to Lua, I believe for performance-related reasons.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: program to generate data helpful in finding duplicate large files

2014-09-22 Thread Chris Kaynor
I went and looked up the PEPs regarding universal new-lines, and it seems
it would be platform-independent - all of "\r\n", "\r", and "\n" will
always be converted to "\n" in Python, unless explicitly modified on the
file object (or Universal newlines are disabled).

It still stands that for platform independence, "rb" should be used due to
some platforms treating binary files differently.

Additionally, and most importantly, for what the OP was doing (determining
if files are the same), you almost certainly want to read the raw bytes -
especially if some of the files are truly binary (such as *.exe on Windows).

Chris

On Mon, Sep 22, 2014 at 12:34 PM,  wrote:

> On Thu, Sep 18, 2014, at 14:45, Chris Kaynor wrote:
> > Additionally, you may want to specify binary mode by using
> > open(file_path,
> > 'rb') to ensure platform-independence ('r' uses Universal newlines, which
> > means on Windows, Python will convert "\r\n" to "\n" while reading the
> > file). Additionally, some platforms will treat binary files differently.
>
> Does 'r' not use universal newlines on unix? If not, why not? The only
> purpose seems to be to allow people to write bad programs and have them
> work on unix. It makes even less sense in python 3 where opening a file
> in text mode results in a TextIOWrapper with utf-8 encoding, and
> therefore can't be used on arbitrary binary files.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python advice

2014-09-22 Thread Chris Kaynor
On Mon, Sep 22, 2014 at 12:39 PM, Ian Kelly  wrote:

> On Mon, Sep 22, 2014 at 1:00 PM, Chris Kaynor 
> wrote:
> > Python is pretty good base-line language. It is really good as a glue
> > language to piece together other components, or for IO-bound or
> user-bound
> > code, but will not preform well enough for many other applications such
> as
> > games. It is good for short parts of games, but a full next-gen engine
> would
> > be much too slow if written in pure Python, however Civilization 5 uses
> > Python as its scripting language. There are also libraries available that
> > can provide enough performance to do basic games in Python.
>
> Correction: Civilization 4 used Python for scripting. For Civilization
> 5 they switched to Lua, I believe for performance-related reasons.
>

I stand corrected. A quick search shows you are correct, for all of Civ4
using Python, Civ5 using Lua, and the primary reason being performance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [python-committers] [RELEASE] Python 3.4.2rc1 is now available

2014-09-22 Thread Larry Hastings


On 09/22/2014 03:58 PM, Victor Stinner wrote:

Someone broke test_pydoc. Example:
http://buildbot.python.org/all/builders/AMD64%20FreeBSD%2010.0%203.4/builds/481/steps/test/logs/stdio


I broke it while making the release.  Known bug, happened before, for 
3.4.1rc1.


   http://bugs.python.org/issue21431

We'll get it right for 3.4.2 final.  I don't think we need to respin 
3.4.2rc1 / add a 3.4.2rc2 for this.




On 09/22/2014 06:02 PM, Terry Reedy wrote:

On 9/22/2014 10:15 AM, Larry Hastings wrote:

You can download it here:

https://www.python.org/download/releases/3.4.2

Unfortunately, I cannot. This actually links to
https://www.python.org/download/releases/3.4.1


WFM.  I'm guessing this was a CDN caching problem--I forgot to manually 
purge the cache.  Does it work for you now?



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


Re: program to generate data helpful in finding duplicate large files

2014-09-22 Thread Terry Reedy

On 9/22/2014 3:34 PM, random...@fastmail.us wrote:

On Thu, Sep 18, 2014, at 14:45, Chris Kaynor wrote:

Additionally, you may want to specify binary mode by using
open(file_path,
'rb') to ensure platform-independence ('r' uses Universal newlines, which
means on Windows, Python will convert "\r\n" to "\n" while reading the
file). Additionally, some platforms will treat binary files differently.


Does 'r' not use universal newlines on unix?


'r' in the open mode means 'read', versus 'w' for 'write' and 'a' for 
'append'.  'b' means 'binary', versus 't' for 'text'.  I am pretty sure 
universal newlines only applies to text mode, as least in 3.x.


--
Terry Jan Reedy


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


Re: Python advice

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 5:00 AM, Chris Kaynor  wrote:
> As a rule-of-thumb I'd recommend sticking to one or two high-level languages
> until you are reasonably comfortable with them, then possibly branching to
> other languages. As you've already started with Python, I'd continue on it
> for a while. Possibly throw in Javascript/HTML/CSS for web-development - for
> server-side code you could look in the to various Python web frameworks, or
> learn PHP for those.

Let's start with application programming languages... pick up the
other languages separately. I'd strengthen the recommendation: As
you've already started with Python, and as Python is an excellent
language, I'd recommend continuing with it for a good while. Don't
bother with PHP.

> A few languages and their major strengths:
>
> Python is pretty good base-line language. It is really good as a glue
> language to piece together other components, or for IO-bound or user-bound
> code, but will not preform well enough for many other applications such as
> games. It is good for short parts of games, but a full next-gen engine would
> be much too slow if written in pure Python, however Civilization 5 uses
> Python as its scripting language. There are also libraries available that
> can provide enough performance to do basic games in Python.

Agreed (with the minor correction re Civ 4/5 and Lua, per other
posts); but you'd be amazed how much can be done in the "slow
language". There are two common models for mixing Python and some
lower-level, higher performance language: either you use the high
performance language as the main program and then script a few parts
in Python to make them customizable, or you use Python as the main
program and use the other language to do the heavy lifting via
well-defined API calls. The latter is extremely well-suited to
heavy-duty mathematical computation - you can do enormous amounts of
work with numpy, and all the grunt-work is done in Fortran, even
though you just write pure Python code.

> C# is another good base-line language, although its much more limited to
> Windows (there are ways to run it on Mac and Linux, but not as easily). The
> main benefit it has is that, if you have Visual Studio, you get a nice UI
> designer built-in. Overall, this is a decent option for Windows-only GUI
> applications, and can be expanded with other libraries to other platforms,
> including many mobile platforms. Some web-servers can also run it as a
> server-side language.

I haven't used it extensively, but I'm given to believe that mono
means C# is reasonably viable on Mac/Linux these days. You'd have to
find an expert to be sure, though.

Personally, I don't think C# has anything above other languages, if
you're writing for desktop OSes. But mobile is a completely different
story, and if you can write one codebase that runs on Windows, Mac,
Linux, and whatever phone you're targeting, that's a huge win.
Otherwise, though, don't bother learning C#, at least for now.

> Javascript is basically a necessity for web-based applications, as it is the
> only language that is commonly runnable across all browsers. There are,
> however, compilers that can (with some success) convert other languages to
> Javascript. (note: Javascript runs in the browser, primarily)

JavaScript/ECMAScript is the One Obvious Way to script a web page.
It's also one of the easiest languages to sandbox as a means of
allowing untrusted people to script your program. (It shares this with
Lua, which is a much less powerful language.) Sadly, it's stuck in
UTF-16 land, and that's never going to change (for reasons of backward
compatibility). Learn JS if you want to do anything even slightly
fancy with web pages.

> PHP is another commonly used web language, and is widely supported by
> servers. Anymore, there are also good Python libraries available for
> server-side webpages, although whether you can use them will depend on the
> server you are using. For some of the free servers, even PHP may not be
> supported, and you will only be able to do static sites (no server-side
> code).

A few years ago, PHP was the *only* way to write server-side code for
cheap web hosting. That's changing, but given how terrible a language
PHP is, I would say you're far FAR better off filtering web hosts down
to those that let you run Python code (even if that means paying a
little more) rather than learning PHP. Don't learn PHP unless you have
a really REALLY compelling use-case... maybe there's some existing PHP
framework that does 99.995% of what you want, and the remaining .005%
just requires a tiny bit of your own PHP code. And even then, keep
your eyes open for the possibility of outgrowing that framework.

> C/C++ are both low level, and therefore generally harder to learn but
> provides much better performance than many other languages. I'd recommend
> putting these off until you are more comfortable with other, higher-level
> languages.

Agreed. The primary job of C is to write h

Re: very lightweight gui for win32 + python 3.4

2014-09-22 Thread Tim Roberts
Wolfgang Keller  wrote:
>
>> wxPython and Qt are well known but they are not exactly lightweight.
>
>wxPython not lightweight?
>
>It's just a wrapper of win32.

That's not really accurate.  wxWidgets does expose the Win32 APIs, but the
wrapping is not all that transparent.  And wxPython adds significant
functionality on the top of that.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread alex23

On 23/09/2014 4:25 AM, Chris Angelico wrote:

On Tue, Sep 23, 2014 at 4:24 AM, Chris Kaynor  wrote:

But the thing that requires the comment is the "2", not the "print" or the
"cells". And that comes to a more common issue: any number other than 0 or 1
in code most likely needs a comment (that comment could be merely a variable
name). Values of 0 or 1 may need a comment, but there are plenty of cases
where they are used quite clearly - its much less likely that other numbers
have obvious meaning.


Or in this case, replacing the list with a namedtuple is probably more useful.


Depending on the use case, binding a slice to a name can also help 
clarify things.

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


Re: How to not enable a user to close the root tkinter window

2014-09-22 Thread Nicholas Cannon

The git hub has not actually been updated yet I am working on somethine else 
then committing the update. How would I stop the threads though. I'am using the 
Thread from threading function. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to not enable a user to close the root tkinter window

2014-09-22 Thread Chris Angelico
On Tue, Sep 23, 2014 at 3:49 PM, Nicholas Cannon
 wrote:
> The git hub has not actually been updated yet I am working on somethine else 
> then committing the update. How would I stop the threads though. I'am using 
> the Thread from threading function.
>

Ah, okay. (Side point: I recommend committing early and often, it
makes it much easier to go back and look at stuff later.) The easiest
way is to just set a global variable, and then have the thread
periodically check that - once it's set, it shuts itself down.

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


Re: Google Appengine Proxy Post method error

2014-09-22 Thread Kev Dwyer
alextr...@googlemail.com wrote:

> So I got the Labnol Google Appengine proxy but it can't handle the Post
> method aka error 405.
> 
> I need help adding this method to the script:
> 
> mirror.py = http://pastebin.com/2zRsdi3U
> 
> transform_content.py = http://pastebin.com/Fw7FCncA
> 
> main.html = http://pastebin.com/HTBH3y5T
> 
> All other files are just small files for appengine that don't carry
> sufficient code for this. Hope you guys can help.
> 
> Thanks in advance :)


Hello,

Very broadly speaking, you need to add a post method to the MirrorHandler  
class, and in that method:

 - mung the request in a similar fashion to the get method
 - avoid caching the request (POST requests are not idempotent)
 - forward the altered request to the destination server
 - return the response to the original client


The labnol google-proxy githubpage lists a twitter account for support 
contact - http://twitter.com/labnol - so you could try asking there for more 
help.  Also check the docs for webapp2 and and Google App Engine 
(http://developers.google.com/appengine).  

Have fun,

Kev 

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


After install python2.7.3 from source code, no module named array

2014-09-22 Thread Li Tianqing
Hello,
Right now, i install python2.7.3 from source code, but when use it to run 
some script. It raises no module exception.
   Dose `make` not compile array into builtin?





--

Best
Li Tianqing-- 
https://mail.python.org/mailman/listinfo/python-list


After install python2.7.3 from source code, no module named array

2014-09-22 Thread Li Tianqing
I am sorry,  i do not install, i just make, and then use the python under 
source code. If you run 'make install' then some lib will compile and then
will no problem there.


Hello,
Right now, i install python2.7.3 from source code, but when use it to run 
some script. It raises no module exception.
   Dose `make` not compile array into builtin?





--

Best
Li Tianqing


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