Re: Confusing math problem

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote: and you can cast out 1's in binary to find out if it's a multiple of 1, too. O_o I wanna see the numbers that aren't a multiple of 1. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Confusing math problem

2013-02-22 Thread Steven D'Aprano
On Thu, 21 Feb 2013 19:33:32 +, Schizoid Man wrote: Hi there, I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python 2.7.3 on a Mac and I get two different results: Others have already explained that math.pow and the ** exponentiation operator are subtly

subclassable types

2013-02-22 Thread Wolfgang Maier
Dear all, I am wondering what the rules are that determine whether a built-in type is subclassable or not. As examples, why can you base your classes on int or set, but not on bool or range? Also: can you use introspection to find out whether a type is valid as a base type? Thanks for your help!

Re: subclassable types

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - Dear all, I am wondering what the rules are that determine whether a built-in type is subclassable or not. As examples, why can you base your classes on int or set, but not on bool or range? Also: can you use introspection to find out whether a type is valid as

Re: subclassable types

2013-02-22 Thread Sven
I believe it's a matter of choice by BDFL when it comes to bool. These might answer your question: http://mail.python.org/pipermail/python-dev/2002-March/020822.html http://mail.python.org/pipermail/python-dev/2004-February/042537.html specifically: I thought about this last night, and realized

Re: subclassable types

2013-02-22 Thread Wolfgang Maier
Jean-Michel Pichavant jeanmichel at sequans.com writes: Note that range is a function, not a class, hence the error when inheriting from it. I was referring to range in Python3, where it is a class. Should have pointed that out. -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 8:20:20 π.μ. UTC+2, ο χρήστης rob.mar...@gmail.com έγραψε: The datetime function: strptime() DOES check the date for validity. So try something like: from datetime import datetime def get_date(): while True: try: date_in =

Re: Differences creating tuples and collections.namedtuples

2013-02-22 Thread Steven D'Aprano
On Tue, 19 Feb 2013 22:38:32 -0500, Terry Reedy wrote: On 2/18/2013 7:18 PM, Steven D'Aprano wrote: Terry Reedy wrote: On 2/18/2013 6:47 AM, John Reid wrote: I was hoping namedtuples could be used as replacements for tuples in all instances. This is a mistake in the following two

Re: Can't catch CTRL-C when SimpleXMLRPCServer running ?

2013-02-22 Thread Roland Koebler
Hi, I would like to stop the script running in response to a CTRL-C. how about KeyboardInterrupt? try: ... except KeyboardInterrupt: print You pressed Ctrl+C Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: subclassable types

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 09:35:25 +, Wolfgang Maier wrote: Dear all, I am wondering what the rules are that determine whether a built-in type is subclassable or not. The type-designer thought it should, or shouldn't, be. As examples, why can you base your classes on int or set, but not on

Re: subclassable types

2013-02-22 Thread Christian Heimes
Am 22.02.2013 10:35, schrieb Wolfgang Maier: Also: can you use introspection to find out whether a type is valid as a base type? I don't think so. For CPython the information is stored in the type's structure. When type-tp_flags Py_TPFLAGS_BASETYPE is true then subclassing is allowed. But I

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 8:20:20 π.μ. UTC+2, ο χρήστης rob.mar...@gmail.com έγραψε: The datetime function: strptime() DOES check the date for validity. So try something like: from datetime import datetime def get_date(): while True: try: date_in =

Re: NamedTemporaryFile does not match documentation

2013-02-22 Thread Serhiy Storchaka
On 22.02.13 07:57, Jason Friedman wrote: Yep, that looks like a docs bug (it was probably copied straight in from the 2.x docs). Nice and easy to fix, you could submit a patch with the bug report and make the devs love you! Done: http://bugs.python.org/issue17271. Fixed. Thank you. --

Re: Python Newbie

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - Hi Chris, Thanks for this. Regarding ambiguity, you will never find me write ambiguous code. I don't sabotage my own work. But the reality is that in addition to writing my own code, I have to maintain existing. I find it incredibly confusing then I see a

Re: Python Newbie

2013-02-22 Thread Steve Simmons
Dear Mr D'Aprano, I thank you for your post but I must complain in the strongest possible terms that it was not enclosed in the correct delimeters. It should have been enclosed in a humour... /humour pair (or humor.../humor if you are American). I was drinking coffee at the time I started

FYI: AI-programmer

2013-02-22 Thread Gisle Vanem
Here is something interesting that you pythonistas might be interested in: http://www.primaryobjects.com/CMS/Article149.aspx This article describes an experiment to produce an AI program, capable of developing its own programs, using a genetic algorithm implementation with self-modifying

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 10:05 PM, Steve Simmons square.st...@gmail.com wrote: I thank you for your post but I must complain in the strongest possible terms that it was not enclosed in the correct delimeters. It should have been enclosed in a humour... /humour pair (or humor.../humor if you

Re: FYI: AI-programmer

2013-02-22 Thread Duncan Booth
Gisle Vanem gva...@broadpark.no wrote: Here is something interesting that you pythonistas might be interested in: http://www.primaryobjects.com/CMS/Article149.aspx This article describes an experiment to produce an AI program, capable of developing its own programs, using a genetic

Re: FYI: AI-programmer

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 9:11 PM, Gisle Vanem gva...@broadpark.no wrote: Here is something interesting that you pythonistas might be interested in: http://www.primaryobjects.com/CMS/Article149.aspx This article describes an experiment to produce an AI program, capable of developing its own

Re: Confusing math problem

2013-02-22 Thread Serhiy Storchaka
On 22.02.13 11:16, Steven D'Aprano wrote: On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote: and you can cast out 1's in binary to find out if it's a multiple of 1, too. O_o I wanna see the numbers that aren't a multiple of 1. What to be a multiple of means? If A is a multiple of B

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
I'am thinking if somehting like the follwoing work: if( task and ( price and price.isdigit() and price.__len__() = 3 ) and ( date and eval( datetime.strptime(date, '%d %m %Y').strftime('%Y-%m-%d') ) ) ): I just tried it out this workaround so to avoid having an extra try: except: but if

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus nikos.gr...@gmail.com writes: I'am thinking if somehting like the follwoing work: if( task and ( price and price.isdigit() and price.__len__() = 3 ) and ( date and eval( datetime.strptime(date, '%d %m %Y').strftime('%Y-%m-%d') ) ) ): a) you should not (usually) call “dunder

Re: Python Newbie

2013-02-22 Thread Rui Maciel
Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't indent like that; The Go programming language makes that style mandatory. Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't indent like that; The Go programming language makes that style mandatory. [citation needed] What

Re: FYI: AI-programmer

2013-02-22 Thread Gisle Vanem
Chris Angelico ros...@gmail.com wrote: That's not artificial intelligence, though. It's artificial program generation based on a known target output. The Fitness calculation is based on a specific target string. This is fine for devising a program that will produce the entire works of

Re: Issues a longer xpath expression

2013-02-22 Thread Philipp Hagemeister
Hi anonymous, your code is working perfectly right. It's just that the only time that you find anything matching //div[@class=col f-cb] is this one: div class=col f-cb div class=name s-fc3 f-fl名称/div div class=down s-fc3 f-fl视频下载/div div class=desc s-fc3 f-fl课程简介/div /div And

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 2:03:39 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε: Ferrous Cranus nikos.gr...@gmail.com writes: I'am thinking if somehting like the follwoing work: if( task and ( price and price.isdigit() and price.__len__() = 3 ) and ( date and eval(

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
i made a liitle typo at the ned, i meant this: if ( eval( datetime.strptime(date, '%d %m %Y') ) ): date = datetime.strptime(date, '%d %m %Y').strftime('%Y-%m-%d') else: print( Date wasn't entered properly ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus nikos.gr...@gmail.com writes: Let me ask it like this: How can i avoid using try: except: for checkign the date but instead check it with an if statement: Let me answer this way: you can't, without resorting to the simple helper functions I wrote in my previous message. Why

Re: Python Newbie

2013-02-22 Thread Rui Maciel
Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't indent like that; The Go programming language makes that style mandatory.

Re: Issues a longer xpath expression

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - I am having issues with the urllib and lxml.html modules. Here is my original code: import urllib import lxml . html down = 'http://v.163.com/special/visualizingdata/' file = urllib . urlopen ( down ). read () root = lxml . html . document_fromstring ( file )

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 12:35 AM, Lele Gaifax l...@metapensiero.it wrote: Ferrous Cranus nikos.gr...@gmail.com writes: Let me ask it like this: How can i avoid using try: except: for checkign the date but instead check it with an if statement: Let me answer this way: you can't, without

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 12:50 AM, Rui Maciel rui.mac...@gmail.com wrote: Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Andreas Perstinger
Lele Gaifax l...@metapensiero.it wrote: Ferrous Cranus nikos.gr...@gmail.com writes: Let me ask it like this: How can i avoid using try: except: for checkign the date but instead check it with an if statement: Let me answer this way: you can't, without resorting to the simple helper functions

Re: Python Newbie

2013-02-22 Thread Duncan Booth
Rui Maciel rui.mac...@gmail.com wrote: Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't indent like that; The Go

Re: Python Newbie

2013-02-22 Thread Steve Simmons
On 22/02/2013 15:26, Duncan Booth wrote: Rui Maciel rui.mac...@gmail.com wrote: Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs

res - a tiny command-line REST client

2013-02-22 Thread Jared Wright
I made this to explore with the libraries requests, and docopt. Tell me what you think, and if you see a bug make a git issue if you'd like. https://github.com/jawerty/res -- http://mail.python.org/mailman/listinfo/python-list

encoding error in python 27

2013-02-22 Thread Hala Gamal
my code works well with english file but when i use text file encodedeutf-8 my file contain some arabic letters it doesn't work. my code: # encoding: utf-8 from whoosh import fields, index import os.path import re,string import codecs from whoosh.qparser import QueryParser # This list associates

Re: Python Newbie

2013-02-22 Thread Duncan Booth
Steve Simmons square.st...@gmail.com wrote: On 22/02/2013 15:26, Duncan Booth wrote: Rui Maciel rui.mac...@gmail.com wrote: Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me.

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 1:45 AM, Steve Simmons square.st...@gmail.com wrote: Oooh, this is making my head spin. Are you saying that the OP's question about proper indentation has resulted in an incorrectly answered post due to poor indentation of a reference to the indentation of another

Number validation issue

2013-02-22 Thread Morten Engvoldsen
Hi , I have wrote the below code to validate a number using modulus 10 and 11: def is_valid_number(checknum, mod): if mod == 10: if not len(checknum) = 2 and len(checknum) =25: return False number = tuple(int(i) for i in reversed(str(checknum)) ) return

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 3:35:31 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε: Ferrous Cranus nikos.gr...@gmail.com writes: Let me ask it like this: How can i avoid using try: except: for checkign the date but instead check it with an if statement: Let me answer this

Re: FYI: AI-programmer

2013-02-22 Thread Neil Cerutti
On 2013-02-22, Gisle Vanem gva...@broadpark.no wrote: Disregarding the probability math in the above, the question IMHO boils down to whether art can be produced by accident (quote from above). I seems to recall elephant painting selling for lots of dollars some years ago. And long dull poems

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus nikos.gr...@gmail.com writes: but the try: solution is much more less hassle. ... not to mention it is more effective than your simplicistic check :-) ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver

Re: Number validation issue

2013-02-22 Thread Alec Taylor
Out[1]: '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29' In [2]: [not len(x) = 2 and len(x)=25 for x in _] Out[2]: [True]*79 # shorthand to prevent spam I trust you can see the error now! On Sat, Feb 23, 2013 at 2:09 AM, Morten Engvoldsen mortene...@gmail.com

Re: Number validation issue

2013-02-22 Thread Alec Taylor
Whoops, my mistake: In [5]: [not len(x) = 2 and len(x)=25 for x in [str(y) for y in xrange(30)]] Out [5]: [True]*10, [False]*20 But still, I'm guessing that's not the result you were looking for… On Sat, Feb 23, 2013 at 2:30 AM, Alec Taylor alec.tayl...@gmail.com wrote: Out[1]: '0 1 2 3 4 5 6

Re: encoding error in python 27

2013-02-22 Thread Peter Otten
Hala Gamal wrote: my code works well with english file but when i use text file encodedeutf-8 my file contain some arabic letters it doesn't work. my code: with codecs.open(tt.txt,encoding='utf-8') as txtfile: Try encoding=utf-8-sig in the above to remove the byte order mark (BOM) upon

gevent + urllib2 blocking

2013-02-22 Thread 月忧茗
Hi, One problem, thanks for help. import gevent.monkey gevent.monkey.match_all() from lxml import etree # I using xpath parse the html def _get(p): url = BUILD_URL(p) html = urllib2.urlopen(url) # RUN AT HERE AND BLOCKING # ver1 tree = etree.parse(html, parse) #

Re: PyQT app accessible over network?

2013-02-22 Thread Wolfgang Keller
I've been working at learning python off and on now for a while, with a couple programs in mind as a goal - kind of specialized stuff that I can't seem to find a good match for already available, competitor records, score-keeping results for an amateur sports tournament. So you want to

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Tim Chase
On 2013-02-22 07:07, Ferrous Cranus wrote: Actually it can, but instead of try: i have to create a function: def is_sane_date(date): parts = [int(part) for part in date.split() if part.isdigit()] if len(parts) == 3 and \ 1 = parts[0] = 31 and \ 1 = parts[1] = 12

How to write a language parser ?

2013-02-22 Thread Timothy Madden
Hello I am trying to write a DBGp client in python, to be used for debugging mostly php scripts. Currently the XDebug module for php allows me to set breakpoints on any line, include blank ones and lines that are not considered executable, resulting in breakpoints that will never be hit,

Re: Number validation issue

2013-02-22 Thread Morten Engvoldsen
Hi, Thanks for your reply. Here in your code i think you didn't multiply the given number with the weight i have mentioned. The each digit of the given number should multiply with weight ...4,3,2,7,6, 5, 4, 3, 2, 7, 6, 5, 4, 3,2, 1 in this format. That is in detail: To verify the

Re: How to write a language parser ?

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 3:29 AM, Timothy Madden terminato...@gmail.com wrote: For that I would like to write a php parser, in order to detect the proper breakpoints line for statements spanning multiple lines. Are you able to drop to PHP itself for that? It makes its own lexer available to

Re: Number validation issue

2013-02-22 Thread Morten Engvoldsen
Hi, Just to clear the confusion: i am talking about below part of my code: elif mod == 11: if not len(checknum)!= 11: return False weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1] return (sum(w * int(x) for w, x in zip(weights, checknum)) % 11) ==0 for which i

Re: PyQT app accessible over network?

2013-02-22 Thread Monte Milanuk
Yes, I am looking at a database-centric application. I know that the 'larger' databases such as PostgreSQL, MySQL, etc. would not have any problem handling that small amount of traffic. My concern is that using postgres or mysql for this would be akin to using a sledgehammer to swat a fly,

Re: PyQT app accessible over network?

2013-02-22 Thread Alec Taylor
Monte: I noticed you mentioned web2py; that would be my recommendation. You also mention different features being available to different users; perfect use-case for web2py's built-in RBAC. Scalability: Go with Postgres, MySQL; or considering how much data you're talking about, even SQLite would

Re: Urllib's urlopen and urlretrieve

2013-02-22 Thread Dave Angel
On 02/22/2013 12:09 AM, qoresu...@gmail.com wrote: Initially I was just trying the html, but later when I attempted more complicated sites that weren't my own I noticed that large bulks of the site were lost in the process. The urllib code essentially looks like what I was trying but it

Re: Urllib's urlopen and urlretrieve

2013-02-22 Thread MRAB
[snip] As for which version if Python, I have been using Python 2 to learn on as I heard that Python 3 was still largely unadopted due to a lack of library support etc... by comparison. Are people adopting it fast enough now that I should consider learning on 3 instead of 2? [snip] You

Re: subclassable types

2013-02-22 Thread Daniel Urban
On Fri, Feb 22, 2013 at 12:00 PM, Christian Heimes christ...@python.org wrote: Am 22.02.2013 10:35, schrieb Wolfgang Maier: Also: can you use introspection to find out whether a type is valid as a base type? I don't think so. For CPython the information is stored in the type's structure.

Re: Number validation issue

2013-02-22 Thread Morten Engvoldsen
Hi, My below code is wrong : elif mod == 11: if not len(checknum)!= 11: return False weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1] return (sum(w * int(x) for w, x in zip(weights, checknum)) % 11) ==0 it works for 9 digit number , not 11 digit number, so i

Re: encoding error in python 27

2013-02-22 Thread MRAB
On 2013-02-22 14:55, Hala Gamal wrote: my code works well with english file but when i use text file encodedeutf-8 my file contain some arabic letters it doesn't work. my code: # encoding: utf-8 from whoosh import fields, index import os.path import re,string import codecs from whoosh.qparser

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 5:25:41 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε: Ferrous Cranus nikos.gr...@gmail.com writes: but the try: solution is much more less hassle. ... not to mention it is more effective than your simplicistic check :-) ciao, lele. --

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 7:38:47 μ.μ. UTC+2, ο χρήστης Ferrous Cranus έγραψε: Τη Παρασκευή, 22 Φεβρουαρίου 2013 5:25:41 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε: Ferrous Cranus nikos.gr...@gmail.com writes: but the try: solution is much more less hassle.

Shebang line on Windows?

2013-02-22 Thread Walter Hurry
I use FreeBSD or Linux, but my son is learning Python and is using Windows. My question is this: Would it be good practice for him to put #!/usr/bin/ env python at the top of his scripts, so that if made executable on *nix they will be OK? As I understand it this will have no effect on Windows

Re: Number validation issue

2013-02-22 Thread Morten Engvoldsen
Hi, Just to make it more clear: I am looking for how to generate the weight in : 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7.. format for any length of number instead of weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1] only for fixed digit. My below code can check only for 9 digit, so

Re: Shebang line on Windows?

2013-02-22 Thread Dave Angel
On 02/22/2013 01:16 PM, Walter Hurry wrote: I use FreeBSD or Linux, but my son is learning Python and is using Windows. My question is this: Would it be good practice for him to put #!/usr/bin/ env python at the top of his scripts, so that if made executable on *nix they will be OK? As I

Re: Shebang line on Windows?

2013-02-22 Thread Zachary Ware
On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry walterhu...@lavabit.com wrote: I use FreeBSD or Linux, but my son is learning Python and is using Windows. My question is this: Would it be good practice for him to put #!/usr/bin/ env python at the top of his scripts, so that if made executable

Re: Number validation issue

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 11:27 AM, Morten Engvoldsen mortene...@gmail.com wrote: Hi, Just to make it more clear: I am looking for how to generate the weight in : 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7.. format for any length of number instead of weights = [5, 4, 3, 2, 7, 6,

Re: Number validation issue

2013-02-22 Thread Dave Angel
On 02/22/2013 01:27 PM, Morten Engvoldsen wrote: Hi, Just to make it more clear: I am looking for how to generate the weight in : 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7.. format for any length of number instead of weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 1] only for fixed

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 4:41 AM, Chris Angelico ros...@gmail.com wrote: That's not artificial intelligence, though. It's artificial program generation based on a known target output. The Fitness calculation is based on a specific target string. This is fine for devising a program that will

Re: FYI: AI-programmer

2013-02-22 Thread Andrew Robinson
On 02/22/2013 07:21 PM, Ian Kelly wrote: On Fri, Feb 22, 2013 at 4:41 AM, Chris Angelico ros...@gmail.com wrote: That's not artificial intelligence, though. It's artificial program generation based on a known target output. The Fitness calculation is based on a specific target string. This is

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 5:09 AM, Andrew Robinson andr...@r3dsolutions.com wrote: On 02/22/2013 07:21 PM, Ian Kelly wrote: I am curious about how he deals with infinite loops in the generated programs. Probably he just kills the threads after they pass some time threshold? I'm under the

Re: FYI: AI-programmer

2013-02-22 Thread Andrew Robinson
On 02/22/2013 08:23 PM, Ian Kelly wrote: On Fri, Feb 22, 2013 at 5:09 AM, Andrew Robinson andr...@r3dsolutions.com wrote: On 02/22/2013 07:21 PM, Ian Kelly wrote: I am curious about how he deals with infinite loops in the generated programs. Probably he just kills the threads after they pass

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 6:04 AM, Andrew Robinson andr...@r3dsolutions.com wrote: It's still surprising that even C# would allow a killing of threads. Resources can be allocated by a thread and tied up was one of the comments made on the site I linked; so those resources could be permanently

Re: FYI: AI-programmer

2013-02-22 Thread Oscar Benjamin
On 22 February 2013 13:04, Andrew Robinson andr...@r3dsolutions.com wrote: How would you get an interpreter thread to check for a shutdown request every N cycles? I've read about how to set a timeout based on time, but not on any kind of cycle (eg: instruction cycle?) count. Do you have a

Re: Python Newbie

2013-02-22 Thread piterrr . dolinski
Thanks to everyone for all the posts, some friendly some not. I read all of them with genuine interest. So I am continuing to learn Python, here are my new observations for your consideration. There seems to be a heated argument about Python's apparently intentional ambiguity in conditional

Re: PyQT app accessible over network?

2013-02-22 Thread Monte Milanuk
On 02/22/2013 08:57 AM, Alec Taylor wrote: Monte: I noticed you mentioned web2py; that would be my recommendation. You also mention different features being available to different users; perfect use-case for web2py's built-in RBAC. Scalability: Go with Postgres, MySQL; or considering how much

Re: Python Newbie

2013-02-22 Thread Oscar Benjamin
On 22 February 2013 21:37, piterrr.dolin...@gmail.com wrote: Thanks to everyone for all the posts, some friendly some not. I read all of them with genuine interest. So I am continuing to learn Python, here are my new observations for your consideration. There seems to be a heated

Re: subclassable types

2013-02-22 Thread Terry Reedy
On 2/22/2013 4:35 AM, Wolfgang Maier wrote: Dear all, I am wondering what the rules are that determine whether a built-in type is subclassable or not. As examples, why can you base your classes on int or set, but not on bool or range? Also: can you use introspection to find out whether a type is

Re: Basic Listview Example

2013-02-22 Thread Terry Reedy
On 2/22/2013 1:03 PM, Xx7 wrote: Hi, could somebody possibly provide a basic listview example? thanks! Hi, could you possibly explain what you mean by listview? thanks! (There is no such class that I know of.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 2:37 PM, piterrr.dolin...@gmail.com wrote: There seems to be a heated argument about Python's apparently intentional ambiguity in conditional statements. Specifically, the issue is, is it more appropriate to write (as an example) if (some statement):#

Re: Shebang line on Windows?

2013-02-22 Thread James Harris
On Feb 22, 6:40 pm, Zachary Ware zachary.ware+pyl...@gmail.com wrote: On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry walterhu...@lavabit.com wrote: I use FreeBSD or Linux, but my son is learning Python and is using Windows. My question is this: Would it be good practice for him to put

Re: Shebang line on Windows?

2013-02-22 Thread MRAB
On 2013-02-22 22:53, James Harris wrote: On Feb 22, 6:40 pm, Zachary Ware zachary.ware+pyl...@gmail.com wrote: On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry walterhu...@lavabit.com wrote: I use FreeBSD or Linux, but my son is learning Python and is using Windows. My question is this:

Re: PyQT app accessible over network?

2013-02-22 Thread Michael Torrie
On 02/22/2013 02:49 PM, Monte Milanuk wrote: Web2py does seem pretty attractive in that it seems to come with a lot of functionality rolled in already. It seems to be pretty easy to deploy... since this would be more of a case where the volunteer match directors are not necessarily

Re: Basic Listview Example

2013-02-22 Thread Xx7
Listview example in a GUI -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-22 Thread piterrr . dolinski
Hi Ian, Thanks for typing all this for me. Really useful. I did some googling of my own and I found that there was no concept of boolean in older versions of Python like you said. (BTW, how does this omission go well with proper language design, as Oscar seems to have hinted?) I think this

Re: Basic Listview Example

2013-02-22 Thread Terry Reedy
On 2/22/2013 6:36 PM, Xx7 wrote: Listview example in a GUI The documentation for each GUI framework should have an example for each of its widgets. Specific questions about any framework other than tk access though tkinter are probably best directed to framework-specific mailing lists. --

Re: Python Newbie

2013-02-22 Thread Steven D'Aprano
On Sat, 23 Feb 2013 01:05:15 +1100, Chris Angelico wrote: Or else golang.org is wrong. That's certainly possible, but you know what they say about extraordinary claims. They must be true? Extraordinary claims are always true would be an extraordinary claim, and therefore true. I learned this

Re: How to write a language parser ?

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 18:29:42 +0200, Timothy Madden wrote: [...] For that I would like to write a php parser, in order to detect the proper breakpoints line for statements spanning multiple lines. Is there an (open-source) way to do to this in python code ? Try pyparsing:

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 10:38 AM, piterrr.dolin...@gmail.com wrote: I think this obvious shortcomming is the main reason that, for example, when x holds the value of 5, x is considered to be true. You see, I have to maintain Python files (ubuntu server scripts) which are 2000 lines long, all

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 11:03 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 23 Feb 2013 01:05:15 +1100, Chris Angelico wrote: Or else golang.org is wrong. That's certainly possible, but you know what they say about extraordinary claims. They must be true?

Re: Basic Listview Example

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 10:36 AM, Xx7 ...@gmail.com wrote: Listview example in a GUI Sounds to me like you may be talking about GTK, but I'm not 100% sure there. You really need to give a LOT more information. Actually, you'll probably find that Google Search has crystal balls every bit as

Re: PyQT app accessible over network?

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 11:20 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Problem: SQLite3 (and M$ JET/Access) are considered file server databases. Each instance of the program accessing the database is directly opening the database file(s). While SQLite3 has a fairly complex

Re: Python Newbie

2013-02-22 Thread Terry Reedy
On 2/22/2013 4:37 PM, piterrr.dolin...@gmail.com wrote: Yours is the first post here, that I know of, from someone 'forced' to learn and use Python at their job. Several people have instead complained about being prohibited from using Python at work. I am sorry that you have been introduced

Re: Python Newbie

2013-02-22 Thread Mitya Sirenef
On 02/22/2013 06:58 AM, Rui Maciel wrote: Mitya Sirenef wrote: Looks very unclear and confusing to me. Whether it's C# or ruby or anything else, most devs don't indent like that; The Go programming language makes that style mandatory. Rui Maciel I was referring to different

Re: How to write a language parser ?

2013-02-22 Thread mbg1708
On Friday, February 22, 2013 11:29:42 AM UTC-5, Timothy Madden wrote: Hello I am trying to write a DBGp client in python, to be used for debugging mostly php scripts. Currently the XDebug module for php allows me to set breakpoints on any line, include blank ones and lines

Re: Python Newbie

2013-02-22 Thread Mitya Sirenef
On 02/22/2013 04:37 PM, piterrr.dolin...@gmail.com wrote: Thanks to everyone for all the posts, some friendly some not. I read all of them with genuine interest. So I am continuing to learn Python, here are my new observations for your consideration. There seems to be a heated argument

Re: Python Newbie

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 20:47:20 -0500, Mitya Sirenef wrote: It's been used for many important projects by a huge number of big companies: http://www.python.org/about/success/ Unlike Java and C#, it's not backed by a marketing effort of a large company, so its success is entirely due to its

Re: How to write a language parser ?

2013-02-22 Thread Mark Lawrence
On 22/02/2013 16:29, Timothy Madden wrote: Hello I am trying to write a DBGp client in python, to be used for debugging mostly php scripts. Currently the XDebug module for php allows me to set breakpoints on any line, include blank ones and lines that are not considered executable, resulting

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 1:02 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 22 Feb 2013 20:47:20 -0500, Mitya Sirenef wrote: It's been used for many important projects by a huge number of big companies: http://www.python.org/about/success/ Unlike Java and C#, it's

  1   2   3   >