Unit Test case for complie/test

2013-02-22 Thread jitendra gupta
Hi, I am working one tool, which will do compile/run the workspace (that code is written on c/c++). on that my requirment is i need to compile subfolder also, i have wrote code for that also. My problem is , i am unable to write the Unit test case for that. Since my method (called run_subfolder)

Re: Python Newbie

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 13:37:20 -0800, piterrr.dolinski wrote: > Today I learned the hard way that all function parameters in Python are > passed by reference (meaning whatever happens to them inside a function, > new values are always passed to caller). Not good. Today you learned wrong. This is a

Re: Python Newbie

2013-02-22 Thread Mark Lawrence
On 23/02/2013 02:40, Mitya Sirenef wrote: On 02/22/2013 09:18 PM, Chris Angelico wrote: On Sat, Feb 23, 2013 at 1:02 PM, Steven D'Aprano > 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 >>> comp

My script use paramiko module, it will be blocked at compute_hmac

2013-02-22 Thread Jack
Hello one problem, thanks for help My script like this: /hostname = xxx// //username = xxx// //password = xxx// //t = paramiko.Transport((hostname, 22))// //t.connect(username=username, password=password)//# here will be blocked //sftp = paramiko.SFTPClient.from_transport(t)/ I used gdb attach th

Re: Python Newbie

2013-02-22 Thread rurpy
On Friday, February 22, 2013 6:04:21 PM UTC-7, Terry Reedy wrote: >[...] the first 'killer app' for Python was nuclear weapon calculations... Gives a whole new meaning to the phrase "killer app", doesn't it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 1:40 PM, Mitya Sirenef wrote: > It's also worth noting that if there's a new language that is somewhat > better than all established languages, but not to the extent that it > will ever replace them (because of network effects), it's not really > better for any practical pu

Re: Python Newbie

2013-02-22 Thread Mitya Sirenef
On 02/22/2013 09:18 PM, Chris Angelico wrote: On Sat, Feb 23, 2013 at 1:02 PM, Steven D'Aprano > 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/succe

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 1:02 PM, Steven D'Aprano 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 not backed by a marketi

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 in

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 t

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" argu

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

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 i

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 to

Re: PyQT app accessible over network?

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 11:20 AM, Dennis Lee Bieber 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 locking system, t

Re: Basic Listview Example

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 10:36 AM, Xx7 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 good as ours; if y

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 11:03 AM, Steven D'Aprano 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? > > "Extraordinary claims are always tr

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 10:38 AM, 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 > sequential code, n

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: http://pyparsi

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 t

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 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 obvi

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 comp

Re: Basic Listview Example

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

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 wrote: On Fri, Feb 22, 2013 at 12: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

Re: Shebang line on Windows?

2013-02-22 Thread James Harris
On Feb 22, 6:40 pm, Zachary Ware wrote: > On Fri, Feb 22, 2013 at 12: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

Re: Python Newbie

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 2:37 PM, 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):# short form > > rather

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: 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: Python Newbie

2013-02-22 Thread Oscar Benjamin
On 22 February 2013 21:37, 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 about Python's a

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 d

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: FYI: AI-programmer

2013-02-22 Thread Oscar Benjamin
On 22 February 2013 13:04, Andrew Robinson 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 python example? wh

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 6:04 AM, Andrew Robinson 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 tied up > until process

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 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

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 5:09 AM, Andrew Robinson 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 impression that Pyth

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 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 devisin

Re: FYI: AI-programmer

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 4:41 AM, Chris Angelico 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 en

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 digi

Re: Number validation issue

2013-02-22 Thread Ian Kelly
On Fri, Feb 22, 2013 at 11:27 AM, 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]

Re: Shebang line on Windows?

2013-02-22 Thread Zachary Ware
On Fri, Feb 22, 2013 at 12: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

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 underst

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 if

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: 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 writes: > > > > > > > > > > > > > but the try: solution is much more less hassle. > > > >

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 writes: > > > > > but the try: solution is much more less hassle. > > > > ... not to mention it is more effective than your simplicistic check :-) > > > > ciao, lele. > > -- > > nickna

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 encodede"utf-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.qparse

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,

Re: subclassable types

2013-02-22 Thread Daniel Urban
On Fri, Feb 22, 2013 at 12:00 PM, Christian Heimes 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. When type->tp_fl

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 s

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 didn't

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 b

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, wh

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 w

Re: How to write a language parser ?

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 3:29 AM, 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. Are you able to drop to PHP itself for that? It makes its own lexer available to user-code: http://php.ne

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 nu

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, eve

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[

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

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) # ver

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 > encodede"utf-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 (B

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 wrote: > Out[1]: '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

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 wrote: > Hi , > I ha

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus 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 paura di chi mi copia. l

Re: FYI: AI-programmer

2013-02-22 Thread Neil Cerutti
On 2013-02-22, Gisle Vanem 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 written > by c

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 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

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 (s

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 1:45 AM, Steve Simmons 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 reference? ...

Re: Python Newbie

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

encoding error in python 27

2013-02-22 Thread Hala Gamal
my code works well with english file but when i use text file encodede"utf-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 associa

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

Re: Python Newbie

2013-02-22 Thread Steve Simmons
On 22/02/2013 15:26, Duncan Booth wrote: Rui Maciel wrote: Chris Angelico wrote: On Fri, Feb 22, 2013 at 10:58 PM, 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 programmi

Re: Python Newbie

2013-02-22 Thread Duncan Booth
Rui Maciel wrote: > Chris Angelico wrote: > >> On Fri, Feb 22, 2013 at 10:58 PM, 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 m

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Andreas Perstinger
Lele Gaifax wrote: >Ferrous Cranus 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

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Sat, Feb 23, 2013 at 12:50 AM, Rui Maciel wrote: > Chris Angelico wrote: > >> On Fri, Feb 22, 2013 at 10:58 PM, 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; >>> >>> T

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 wrote: > Ferrous Cranus 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 fu

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: Python Newbie

2013-02-22 Thread Rui Maciel
Chris Angelico wrote: > On Fri, Feb 22, 2013 at 10:58 PM, 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. > > [ci

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus 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 do you dislike that

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 Ferrous Cranus
Τη Παρασκευή, 22 Φεβρουαρίου 2013 2:03:39 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε: > Ferrous Cranus 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.strpti

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: 名称 视频下载 课程简介 And obviously, there's no in there, so the xpath won't match. Cheers, Philipp On 02/22/2013 02:24 AM, python wrote

Re: FYI: AI-programmer

2013-02-22 Thread Gisle Vanem
"Chris Angelico" 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 Shakespeare, since the

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 10:58 PM, 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. [citation needed] What do you mean by

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: Checking for valid date input and convert appropriately

2013-02-22 Thread Lele Gaifax
Ferrous Cranus 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 methods” directly,

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

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: FYI: AI-programmer

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 9:11 PM, Gisle Vanem 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, usi

Re: FYI: AI-programmer

2013-02-22 Thread Duncan Booth
Gisle Vanem 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 algorithm

Re: Python Newbie

2013-02-22 Thread Chris Angelico
On Fri, Feb 22, 2013 at 10:05 PM, Steve Simmons 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 ... pair (or ... if you > are American). Steve, you clearly do not un

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-modifyi

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 ... pair (or ... if you are American). I was drinking coffee at the time I started reading your post and,

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 s

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. -- http:

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: > >

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: 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 o

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: 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

  1   2   >