Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Shashwat Anand
Thanks everyone for the insight. I got the idea as to how and where to start. Guess I need to work in Perl for now, so as to start the conversion process. Regarding Tests, I had already started writing tests before posting. Writing tests for every module will be a pain as well as a nice experience.

Re: a little parsing challenge ☺

2011-07-24 Thread John O'Hagan
On Thu, 21 Jul 2011 05:58:48 -0700 (PDT) Xah Lee wrote: [...] > > > On Sunday, July 17, 2011 2:48:42 AM UTC-7, Raymond Hettinger wrote: > > >> On Jul 17, 12:47 am, Xah Lee wrote: > > >>> i hope you'll participate. Just post solution here. Thanks. > > > > >>http://pastebin.com/7hU20NNL > > > > >

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 25, 2:04 am, Gregory Ewing wrote: > Frank Millman wrote: > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > '165.0', and '165.00' are all valid string representations of the > > integer 165.[1] > > > Therefore, for practical purposes, it would not be wrong for python's

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 10:07 AM, Billy Mays wrote: > if the goal is speed, then you should use generator expressions: > > list_of_integers = (int(float(s)) for s in list_of_strings) Clarification: This is faster if and only if you don't actually need it as a list. In spite of the variable name,

Re: Help with Latin Characters

2011-07-24 Thread Benjamin Kaplan
On Sun, Jul 24, 2011 at 3:47 PM, Joao Jacome wrote: > > 2011/7/24 Chris Angelico >> >> On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome wrote: >> > Already tried without unicode string in rootdir, same results. What if try >> > using raw strings? >> >> Raw strings are just another way of typing them

Re: Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
I want to interface to the native validation of tk. If you don't know what that is, you're unlikely to be able to help me. -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Terry Reedy
On 7/24/2011 8:51 PM, Michael Torrie wrote: Now replying to an existing thread to start an entirely new, unrelated thread is definitely rude. Rude or not, it tends to be unproductive. If someone posted "Help with threading internals" here, it could well not be seen by the appropriate people,

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Grant Edwards
On 2011-07-24, John Nagle wrote: > On 7/19/2011 7:34 PM, Andrew Berg wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: RIPEMD160 >> >> There's PyGUI, which, at a glance, fits whit what you want. Looks like >> it uses OpenGL and native GUI facilities. >> http://www.cosc.canterbury.ac.nz/greg.ew

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Michael Torrie
On 07/20/2011 07:17 PM, rantingrick wrote: > Please everyone, do not change the subject of someone's thread > because it's considered rude. Thank you. Too funny. Says who? Changing the subject line to reflect the direction this part of the thread (a branch if you will) is going is definitely ap

Re: Validating Entry in tkinter

2011-07-24 Thread rantingrick
On Jul 24, 7:11 pm, Saul Spatz wrote: > > Can one do something like this in tkinter? ‡ (1) First of all what exactly do you wish return? * an integer * a float * something else? (2) Is this input part of a modal or non-modal interface? For me, input validation should happen in *real* time an

Re: Python for Web

2011-07-24 Thread Dan Stromberg
On Wed, Jun 15, 2011 at 5:11 AM, bruno.desthuilli...@gmail.com < bruno.desthuilli...@gmail.com> wrote: > On Jun 15, 9:50 am, sidRo wrote: > > Is Python only for server side? > > Is it a theoretical question or a practical one ?-) > > More seriously: except for the old proof-of-concept Grail brows

Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
In tcl/tk an Entry widget can be set to validate its contents with the validate option. You have to give it a validatecommand (vcmd), which is a tcl script that runs when some action triggers validation. Usually, the script would use "percent substitutions" so the script would be something lik

Re: Convert '165.0' to int

2011-07-24 Thread Billy Mays
On 7/24/2011 2:27 PM, SigmundV wrote: On Jul 21, 10:31 am, "Frank Millman" wrote: Is there a short cut, or must I do this every time (I have lots of them!) ? I know I can write a function to do this, but is there anything built-in? I'd say that we have established that there is no shortcut, n

Re: Convert '165.0' to int

2011-07-24 Thread Gregory Ewing
Frank Millman wrote: I know I am flogging a dead horse here, but IMHO, '165', '165.', '165.0', and '165.00' are all valid string representations of the integer 165.[1] Therefore, for practical purposes, it would not be wrong for python's 'int' function to accept these without complaining. How

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Gregory Ewing
John Nagle wrote: There's PyGUI, which, at a glance, fits whit what you want. Looks like it uses OpenGL and native GUI facilities. http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ It still uses Tcl/Tk stuff, which is un-Pythonic. You must be thinking of something else. My PyGUI has

Re: python.org is down?

2011-07-24 Thread shbk background
ukraine, connection was lost also... -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Tim Roberts
Gregory Ewing wrote: >Tim Roberts wrote: >> >> I don't think your glibness is justified. There is a legitimate appeal to >> this notion. The fact is that MANY APIs can be completely and adequately >> described by HTML. > >My brain raises a TypeError on that statement. According to >my understa

Tkinter/py2exe with installer

2011-07-24 Thread Kevin Walzer
Can anyone point me in the direction of a Tkinter/Python app that has been wrapped with py2exe and is deployed on Windows as a standalone using one of the standard installer tools? (MSI, NSIS, Inno Setup, etc.) I'm working on a Tkinter app for Windows and have had a surprisingly hard time findi

Re: PEP 8 and extraneous whitespace

2011-07-24 Thread Ben Finney
Zero Piraeus writes: > : > > > It's also because many people report that it's easier to read text when > > it's not wider than ~75 characters. > > That rule [1] is for paragraphs of prose in proportional text; code is > both written and read differently. While there most likely is an upper > limi

Re: Rant on web browsers

2011-07-24 Thread lkcl
On Jun 14, 7:31 am, Chris Angelico wrote: > Random rant and not very on-topic. Feel free to hit Delete and move on. > > I've just spent a day coding in Javascript, and wishing browsers > supported Python instead (or as well). All I needed to do was take two ok your next best thing is to try pyja

Re: Rant on web browsers

2011-07-24 Thread lkcl
On Jun 14, 7:31 am, Chris Angelico wrote: > But if anyone feels like writing an incompatible browser, please can > you add Python scripting? http://wiki.python.org/moin/WebBrowserProgramming already been done, chris - you want the firefox plugin, pyxpcomext and then if you actually want to ma

Re: Python for Web

2011-07-24 Thread lkcl
On Jun 15, 1:11 pm, "bruno.desthuilli...@gmail.com" wrote: > On Jun 15, 9:50 am, sidRo wrote: > > > Is Python only for server side? > > Is it a theoretical question or a practical one ?-) > > More seriously: except for the old proof-of-concept Grail browser, no > known browser uses Python as a cl

Re: Help with Latin Characters

2011-07-24 Thread Joao Jacome
2011/7/24 Chris Angelico > On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome wrote: > > Already tried without unicode string in rootdir, same results. What if > try > > using raw strings? > > Raw strings are just another way of typing them into your source code. > There are different ways of writing

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread lkcl
On Jul 20, 3:34 am, Terry Reedy wrote: > On 7/19/2011 10:12 PM, sturlamolden wrote: > > > > > What is wrong with them: > > > 1. Designed for other languages, particularly C++, tcl and Java. > > > 2. Bloatware. Qt and wxWidgets are C++ application frameworks. (Python > > has a standard library!) >

Re: Help with Latin Characters

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome wrote: > Already tried without unicode string in rootdir, same results. What if try > using raw strings? Raw strings are just another way of typing them into your source code. There are different ways of writing string literals, but they produce the sa

Fwd: Help with Latin Characters

2011-07-24 Thread Joao Jacome
2011/7/24 Terry Reedy > On 7/24/2011 11:15 AM, Joao Jacome wrote: > >> http://pastebin.com/aMrzczt4 >> > >list = os.listdir(dir) > While somewhat natural, using 'list' as a local name and masking the > builtin list function is a *very bad* idea. Someday you will do this and > then use 'li

Aw: python.org back up ?(was Re: python.org is down?)

2011-07-24 Thread David Zerrenner
*pew* I can't live without the docs, that really made my day now. -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-24 Thread SigmundV
On Jul 21, 10:31 am, "Frank Millman" wrote: > Is there a short cut, or must I do this every time (I have lots of them!) ? > I know I can write a function to do this, but is there anything built-in? I'd say that we have established that there is no shortcut, no built- in for this. You write you ow

Re: python.org back up ?(was Re: python.org is down?)

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 4:34 AM, Terry Reedy wrote: > On 7/24/2011 3:43 AM, Laszlo Nagy wrote: >> >> Can it be a problem on my side? I have tried from several different >> computers. I cannot even ping it. > > python.org, bugs.python.org, docs.python.org, pypi.python.org > all work for me now. Ye

python.org back up ?(was Re: python.org is down?)

2011-07-24 Thread Terry Reedy
On 7/24/2011 3:43 AM, Laszlo Nagy wrote: Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. python.org, bugs.python.org, docs.python.org, pypi.python.org all work for me now. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/pytho

Re: Help with Latin Characters

2011-07-24 Thread Terry Reedy
On 7/24/2011 11:15 AM, Joao Jacome wrote: http://pastebin.com/aMrzczt4 list = os.listdir(dir) While somewhat natural, using 'list' as a local name and masking the builtin list function is a *very bad* idea. Someday you will do this and then use 'list(args)' expecting to call the list

Re: python.org is down?

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 3:34 AM, Stefan Behnel wrote: > Laszlo Nagy, 24.07.2011 09:43: >> >> Can it be a problem on my side? I have tried from several different >> computers. I cannot even ping it. > > What's even worse is that PyPI is extremely slow in responding, even up to > connection failures

Re: learning another programing language

2011-07-24 Thread Terry Reedy
On 7/24/2011 4:59 AM, Benjamin Gregg wrote: Hi python was my first language but I need to learn C++ and java for a project (No there isn't an alternative) and I want to know is there any good tutorials or tips for learning C++/java after using python? Learn to meditate so you can deal with the

Re: python.org is down?

2011-07-24 Thread Stefan Behnel
Laszlo Nagy, 24.07.2011 09:43: Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. What's even worse is that PyPI is extremely slow in responding, even up to connection failures. I can live with www.python.org being down for a bit, but PyPI is

Re: python.org is down?

2011-07-24 Thread Chris Angelico
On Mon, Jul 25, 2011 at 3:08 AM, Anna Vester wrote: > On Jul 24, 2011 2:43 AM, "Laszlo Nagy" wrote: >> >> Can it be a problem on my side? I have tried from several different >> computers. I cannot even ping it. > > Looks like it is down for everyone according to this site: > http://www.downforeve

Re: python.org is down?

2011-07-24 Thread Anna Vester
On Jul 24, 2011 2:43 AM, "Laszlo Nagy" wrote: > > Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. Looks like it is down for everyone according to this site: http://www.downforeveryoneorjustme.com/ . Anna http://annavester.com -- http://mail.

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread John Nagle
On 7/19/2011 7:34 PM, Andrew Berg wrote: -BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 There's PyGUI, which, at a glance, fits whit what you want. Looks like it uses OpenGL and native GUI facilities. http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ It has quite a few external depend

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Dan Stromberg
On Sun, Jul 24, 2011 at 2:29 AM, Shashwat Anand wrote: > I am working with a huge codebase of Perl. > The code have zero documentation and zero unit-tests. > It seems like a huge hack. > My condolences. Er, actually, it sounds kind of fun. The underlying database schema is horrid. > So I want t

Re: python.org is down?

2011-07-24 Thread Yash Tulsyan
David Zerrenner writes: > Same here for me. My traceroute seems to hang somewhere in the Netherlands. Confirmed here as well. -- http://mail.python.org/mailman/listinfo/python-list

Re: python.org is down?

2011-07-24 Thread David Zerrenner
Same here for me. My traceroute seems to hang somewhere in the Netherlands. -- http://mail.python.org/mailman/listinfo/python-list

Re: python.org is down?

2011-07-24 Thread Colin J. Williams
On 24-Jul-11 03:43 AM, Laszlo Nagy wrote: Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. The same for me at Noon EST Holland where are you? Colin W. -- http://mail.python.org/mailman/listinfo/python-list

python.org is down?

2011-07-24 Thread Laszlo Nagy
Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. -- http://mail.python.org/mailman/listinfo/python-list

Help with Latin Characters

2011-07-24 Thread Joao Jacome
http://pastebin.com/aMrzczt4 When the script reaches a file with latin characters (ê é ã etc) it crashes. Traceback (most recent call last): File "C:\backup\ORGANI~1\teste.py", line 37, in Retrieve(rootdir); File "C:\backup\ORGANI~1\teste.py", line 25, in Retrieve Retrieve(os.path.jo

Re: PEP 8 and extraneous whitespace

2011-07-24 Thread Zero Piraeus
: > It's also because many people report that it's easier to read text when > it's not wider than ~75 characters. That rule [1] is for paragraphs of prose in proportional text; code is both written and read differently. While there most likely is an upper limit, it's going to be different - large

Re: learning another programing language

2011-07-24 Thread Cousin Stanley
Benjamin Gregg wrote: > > I want to know is there any good tutorials or tips > for learning C++/java after using python? You might find the following site to be useful java information http://mindprod.com/jgloss/jgloss.html -- Stanley C. Kitching Human Being Phoenix, Arizo

Re: PEP 8 and extraneous whitespace

2011-07-24 Thread Michael Brown
On 2011-07-22, John Gordon wrote: > In <98u00kfnf...@mid.individual.net> Neil Cerutti writes: > >> You can fit much more code per unit of horizontal space with a >> proportionally spaced font. As a result, that issue, while valid, >> is significantly reduced. > > Is it? I assume one major reason

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Steven D'Aprano
On Sun, Jul 24, 2011 at 7:29 PM, Shashwat Anand wrote: > How do I start ? > The idea is to rewrite module by module. > But how to make sure code doesn't break ? By testing it. Read up on "test driven development". At this point, you have this: Perl modules: A, B, C, D Python modules: none Pyt

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 7:29 PM, Shashwat Anand wrote: > How do I start ? > The idea is to rewrite module by module. > But how to make sure code doesn't break ? > How can I import perl and python codes in each other ? Can you separate the project into separate executables that call on each other?

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 6:53 PM, Ben Finney wrote: > Frank Millman writes: > >> I know I am flogging a dead horse here, but IMHO, '165', '165.', >> '165.0', and '165.00' are all valid string representations of the >> integer 165.[1] > > I disagree entirely. Once you introduce a decimal point into

Re: learning another programing language

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 6:59 PM, Benjamin Gregg wrote: > Hi > python was my first language but I need to learn C++ and java for a project > (No there isn't an alternative) > and I want to know is there any good tutorials or tips for learning C++/java > after using python? Fiddle. Fiddle, fiddle,

Re: Convert '165.0' to int

2011-07-24 Thread Ben Finney
Frank Millman writes: > On Jul 24, 10:53 am, Ben Finney wrote: > > Frank Millman writes: > > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > > '165.0', and '165.00' are all valid string representations of the > > > integer 165.[1] > > > > I disagree entirely. Once you int

Refactor/Rewrite Perl code in Python

2011-07-24 Thread Shashwat Anand
I am working with a huge codebase of Perl. The code have zero documentation and zero unit-tests. It seems like a huge hack. The underlying database schema is horrid. So I want to rewrite the whole of it in Python. How do I start ? The idea is to rewrite module by module. But how to make sure code

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 10:53 am, Ben Finney wrote: > Frank Millman writes: > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > '165.0', and '165.00' are all valid string representations of the > > integer 165.[1] > > I disagree entirely. Once you introduce a decimal point into the > repr

learning another programing language

2011-07-24 Thread Benjamin Gregg
Hi python was my first language but I need to learn C++ and java for a project (No there isn't an alternative) and I want to know is there any good tutorials or tips for learning C++/java after using python? thanks Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-24 Thread Ben Finney
Frank Millman writes: > I know I am flogging a dead horse here, but IMHO, '165', '165.', > '165.0', and '165.00' are all valid string representations of the > integer 165.[1] I disagree entirely. Once you introduce a decimal point into the representation, you're no longer representing an integer

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 23, 8:28 pm, rantingrick wrote: > On Jul 23, 1:53 am, Frank Millman wrote: > > >-- > > The ideal solution is the one I sketched out earlier - modify python's > > 'int' function to accept strings such as '165.0'. > >---

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 6:21 PM, Frank Millman wrote: > On Jul 24, 10:07 am, Chris Angelico wrote: >> if dec.rtrim('0')!='': >> >> ChrisA > > I think you meant 'rstrip', but yes, neater and faster. > > Thanks Yeah, I did. Mea culpa... every language has it somewhere, but I keep mucking up which

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 10:07 am, Chris Angelico wrote: > On Sun, Jul 24, 2011 at 5:58 PM, Frank Millman wrote: > >  if int(dec) != 0: > > to > >    if [_ for _ in list(dec) if _ != '0']: > > if dec.rtrim('0')!='': > > ChrisA I think you meant 'rstrip', but yes, neater and faster. Thanks Frank -- http://m

Re: Convert '165.0' to int

2011-07-24 Thread Chris Angelico
On Sun, Jul 24, 2011 at 5:58 PM, Frank Millman wrote: >  if int(dec) != 0: > to >    if [_ for _ in list(dec) if _ != '0']: > if dec.rtrim('0')!='': ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-24 Thread Thomas 'PointedEars' Lahn
Billy Mays wrote: > On 7/21/2011 10:40 PM, Thomas 'PointedEars' Lahn wrote: >> Billy Mays wrote: >>> On 07/21/2011 08:46 AM, Web Dreamer wrote: If you do not want to use 'float()' try: int(x.split('.')[0]) >>> >>> This is right. >> >> Assuming that the value of `x' is in the proper

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 9:34 am, Steven D'Aprano wrote: > Frank Millman wrote: > > If I really wanted to be 100% safe, how about this - > > >     def get_int(s): > >         if '.' in s: > >             num, dec = s.split('.', 1) > >             if dec != '': > >                 if int(dec) != 0: > >          

Re: Convert '165.0' to int

2011-07-24 Thread Ben Finney
Steven D'Aprano writes: > As a toy for learning about regexes, that's fine, but I trust you would > never use that in production. There are less verbose ways of wasting time > and memory. +1 QotW -- \ “I may disagree with what you say, but I will defend to the | `\death your

Re: Convert '165.0' to int

2011-07-24 Thread Steven D'Aprano
Frank Millman wrote: > If I really wanted to be 100% safe, how about this - > > def get_int(s): > if '.' in s: > num, dec = s.split('.', 1) > if dec != '': > if int(dec) != 0: > raise ValueError('Invalid literal for int') >

Strings show as brackets with a 'u'. Hi, ...[u'174'] ...Probably newbie question but not sure how suppress the brackets and the 'u' ? I assume pyhon is telling me it's a unicode string in the n variab

2011-07-24 Thread Saranya Sweet
http://123maza.com/65/beauty147/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-24 Thread Steven D'Aprano
Billy Mays wrote: > I'll probably get flak for this, but damn the torpedoes: > > def my_int(num): > import re > try: > m = re.match('^(-?[0-9]+)(.0)?$', num) > return int(m.group(1)) As a toy for learning about regexes, that's fine, but I trust you would never use tha

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 23, 5:12 pm, Billy Mays wrote: > On 7/23/2011 3:42 AM, Chris Angelico wrote: > > > > > int(s.rstrip('0').rstrip('.')) > > Also, it will (in?)correct parse strings such as: > > '16500' > > to 165. > > -- > Bill True enough. If I really wanted to be 100% safe, how ab