Re: Tabs -vs- Spaces: Tabs should have won.
* 2011-07-18T10:54:40+10:00 * Steven D'Aprano wrote: Back in 2007, a n00b calling himself TheFlyingDutchman who I am *reasonably* sure was Rick decided to fork Python: http://mail.python.org/pipermail/python-list/2007-September/1127123.html I don't know if they are the same person but quite recently TheFlyingDutchman tried to understand symbols, variables' scope, bindings as well as function and variable namespaces in Common Lisp. It resulted in a long thread, some of it was quite interesting. http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/36000a1f37ebb052/5683597dd587fa87 -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Steven D'Aprano wrote: Why 78? Because it's one less than 79, as mandated by PEP 8, and two less than 80, the hoary old standard. There's another possible reason for the number 78, although hopefully it doesn't still apply today. There's an application I work with that stores free text in database records of 78 chars each. I suspect it's because early versions go back to the MS-DOS era, when it was common to make windows out of box-drawing characters. 80 columns minus two border chars equals 78! -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
I don't know why, but I just had to try it (even though I don't usually use Perl and had to look up a lot of stuff). I came up with this: /(?| (\()(?matched)([\}\]”›»】〉》」』]|$) | (\{)(?matched)([\)\]”›»】〉》」』]|$) | (\[)(?matched)([\)\}”›»】〉》」』]|$) | (“)(?matched)([\)\}\]›»】〉》」』]|$) | (‹)(?matched)([\)\}\]”»】〉》」』]|$) | («)(?matched)([\)\}\]”›】〉》」』]|$) | (【)(?matched)([\)\}\]”›»〉》」』]|$) | (〈)(?matched)([\)\}\]”›»】》」』]|$) | (《)(?matched)([\)\}\]”›»】〉」』]|$) | (「)(?matched)([\)\}\]”›»】〉》』]|$) | (『)(?matched)([\)\}\]”›»】〉》」]|$)) (?(DEFINE)(?matched(?: \((?matched)\) | \{(?matched)\} | \[(?matched)\] | “(?matched)” | ‹(?matched)› | «(?matched)» | 【(?matched)】 | 〈(?matched)〉 | 《(?matched)》 | 「(?matched)」 | 『(?matched)』 | [^\(\{\[“‹«【〈《「『\)\}\]”›»】〉》」』]++)*+)) /sx; If the pattern matches, there is a mismatched bracket. $1 is set to the mismatched opening bracket. $-[1] is its location. $2 is the mismatched closing bracket or '' if the bracket was never closed. $-[2] is set to the location of the closing bracket or the end of the string if the bracket wasn't closed. I didn't write all that manually; it was generated with this: my @open = ('\(','\{','\[','“','‹','«','【','〈','《','「','『'); my @close = ('\)','\}','\]','”','›','»','】','〉','》','」','』'); '(?|'.join('|',map {'('.$open[$_].')(?matched)(['.join('',@close[0..($_-1),($_+1)..$#close]).']|$)'} (0 .. $#open)).')(?(DEFINE)(?matched(?:'.join('|',map {$open[$_].'(?matched)'.$close[$_]} (0 .. $#open)).'|[^'.join('',@open,@close).']++)*+))' -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Rouslan Korneychuk, 18.07.2011 09:09: I don't know why, but I just had to try it (even though I don't usually use Perl and had to look up a lot of stuff). I came up with this: /(?| (\()(?matched)([\}\]”›»】〉》」』]|$) | (\{)(?matched)([\)\]”›»】〉》」』]|$) | (\[)(?matched)([\)\}”›»】〉》」』]|$) | (“)(?matched)([\)\}\]›»】〉》」』]|$) | (‹)(?matched)([\)\}\]”»】〉》」』]|$) | («)(?matched)([\)\}\]”›】〉》」』]|$) | (【)(?matched)([\)\}\]”›»〉》」』]|$) | (〈)(?matched)([\)\}\]”›»】》」』]|$) | (《)(?matched)([\)\}\]”›»】〉」』]|$) | (「)(?matched)([\)\}\]”›»】〉》』]|$) | (『)(?matched)([\)\}\]”›»】〉》」]|$)) (?(DEFINE)(?matched(?: \((?matched)\) | \{(?matched)\} | \[(?matched)\] | “(?matched)” | ‹(?matched)› | «(?matched)» | 【(?matched)】 | 〈(?matched)〉 | 《(?matched)》 | 「(?matched)」 | 『(?matched)』 | [^\(\{\[“‹«【〈《「『\)\}\]”›»】〉》」』]++)*+)) /sx; If the pattern matches, there is a mismatched bracket. $1 is set to the mismatched opening bracket. $-[1] is its location. $2 is the mismatched closing bracket or '' if the bracket was never closed. $-[2] is set to the location of the closing bracket or the end of the string if the bracket wasn't closed. I didn't write all that manually; it was generated with this: my @open = ('\(','\{','\[','“','‹','«','【','〈','《','「','『'); my @close = ('\)','\}','\]','”','›','»','】','〉','》','」','』'); '(?|'.join('|',map {'('.$open[$_].')(?matched)(['.join('',@close[0..($_-1),($_+1)..$#close]).']|$)'} (0 .. $#open)).')(?(DEFINE)(?matched(?:'.join('|',map {$open[$_].'(?matched)'.$close[$_]} (0 .. $#open)).'|[^'.join('',@open,@close).']++)*+))' That's solid Perl. Both the code generator and the generated code are unreadable. Well done! Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On Sunday, July 17, 2011 08:24:12 PM Dotan Cohen did opine: On Sun, Jul 17, 2011 at 17:29, gene heskett ghesk...@wdtv.com wrote: I'm still looking for the perfect programming font. Suggestions welcomed. When you find it Dotan, let me know, I've been looking since the later '70's. Hey there Gene! Are you not on every mailing list on the internet old man?!? Nope, I miss quite a few in fact. Old? I might be looking at 77 yo in a couple months, and a few things don't work anymore because I'm too sweet (type 2 diabetic), but I can occasionally claim to be a JOAT in a serious tone of voice. Hell Dotan, I even know how vacuum tubes work, including some of the exotic ones, like klystrons. I had to wait till they had invented transistors before I could use my first one, 10 years after I had decided I wanted to be an electronics whiz in about '39 cuz my uncle kept himself in beer money fixing radios. I have also come to the conclusion that the perfect woman, the perfect physics theory, and the perfect programming font are all illusions that men will stride their entire lives in search for but will never find. ROTFLMAO! And right you are. It took me several decades (and 3 women I'll explain someday) to reach that conclusion. Cheers, gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) The person who makes no mistakes does not usually make anything. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for general advice on complex program
On Mon, Jul 18, 2011 at 1:33 PM, Josh English joshua.r.engl...@gmail.com wrote: Sadly, I'm the type of guy who almost has to re-invent the wheel. When I started XML processing, it was on an old computer and I couldn't get things like lxml to work, or understand the ones I did manage to install. To fully understand XML processing and validating, I had to write my own XML validation utility. Actually, this isn't a bad thing. Writing your own XML validator is an excellent way to gain proper comprehension of XML. Look up all the specifications and be sure that your parser complies with them, and you'll truly understand what XML is all about. For production code, it's often better to take a ready-made solution, if only to save you the trouble of coding it. But for learning, taking someone else's code can lead to black-box mentality - I push this in here and I get that out there - which can lead to all sorts of ridiculous piles of overlaid protocols. Yes, I've seen some pretty dumb stuff floating around! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Ordered list question
On Mon, Jul 18, 2011 at 2:12 PM, jyoun...@kc.rr.com wrote: Can you share a website that goes into more detail on this good variable naming? I'd Google that one. You'll find more articles than you can read in a lifetime... ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 07/18/2011 03:24 AM, Stefan Behnel wrote: That's solid Perl. Both the code generator and the generated code are unreadable. Well done! Stefan Why, thank you. -- http://mail.python.org/mailman/listinfo/python-list
Partial Function Application -- Advantages over normal function?
Hi, I am a newbie in python and would like to learn GUI programming. I would like to know what exactly is Partial Function Applicaton (functool.partial())? Or how is it advantageous compared to normal functions? Or is there any advantange? Thanks in advance. Regards, Kurian Thayil. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. -tkc (expecting somebody to come back with a bit more retro-computing Four Yorkshiremen bit...spinning 360k 5.25 floppy drives? We should be so lucky. I had to hand jump 2000-amp bits with only my tongue, for a CPU architecture invented by Navajo code-talkers...) -- http://mail.python.org/mailman/listinfo/python-list
Re: Argparse, and linking to methods in Subclasses
with global: SERVER = None A the end of Argparse declarations: parser_check.set_defaults(action=do_the_check) parser_build.set_defaults(action=do_the_build) Then declare the action functions: def do_the_check(namespace_args): if not SERVER: SERVER = Server(namespace_arg.type_of_server) SERVER.check() def do_the_build(namespace_args): if not SERVER: SERVER = Server(namespace_arg.type_of_server) SERVER.build() If I correctly understood your issue. Regards Karim On 07/18/2011 03:48 AM, Victor Hooi wrote: Hi, I have a simple Python script to perform operations on various types on in-house servers: manage_servers.pyoperation type_of_server Operations are things like check, build, deploy, configure, verify etc. Types of server are just different types of inhouse servers we use. We have a generic server class, then specific types that inherit from that: class Server def configure_logging(self, loggin_file): ... def check(self): ... def deploy(self): ... def configure(self): ... def __init__(self, hostname): self.hostname = hostname logging = self.configure_logging(LOG_FILENAME) class SpamServer(Server): def check(self): ... class HamServer(Server): def deploy(self): ... My question is how to link that all up to argparse? Originally, I was using argparse subparses for the operations (check, build, deploy) and another argument for the type. subparsers = parser.add_subparsers(help='The operation that you want to run on the server.') parser_check = subparsers.add_parser('check', help='Check that the server has been setup correctly.') parser_build = subparsers.add_parser('build', help='Download and build a copy of the execution stack.') parser_build.add_argument('-r', '--revision', help='SVN revision to build from.') ... parser.add_argument('type_of_server', action='store', choices=types_of_servers, help='The type of server you wish to create.') Normally, you'd link each subparse to a method - and then pass in the type_of_server as an argument. However, that's slightly backwards due to the classes- I need to create an instance of the appropriate Server class, then call the operation method inside of that. Any ideas of how I could achieve the above? Perhaps a different design pattern for Servers? Or a way to use argparse in this situation? Thanks, Victor -- http://mail.python.org/mailman/listinfo/python-list
Re: Argparse, and linking to methods in Subclasses
Here is an example by using my own library plac (http://pypi.python.org/pypi/plac): class Server(): def configure_logging(self, logging_file): pass def check(self): pass def deploy(self): pass def configure(self): pass def __init__(self, hostname): self.hostname = hostname class SpamServer(Server): def check(self): pass class HamServer(Server): def deploy(self): pass def main(classname, hostname, methname): # add error checking at will instance = globals()[classname](hostname) getattr(instance, methname)() if __name__ == '__main__': import plac; plac.call(main) -- http://mail.python.org/mailman/listinfo/python-list
open urls in browser
Hi All, I am new to python. Before posting i have done some google regarding my question. But i didn't get exact information. So thought of posting it here. I want to open a list of urls in browser that too in same window with out exiting. it should load one by one on same window and also it should log the details simultaneously to another text file. Ex: http://www.google.com - Pass/Fail. If you guys already having this code please share it with me. Thanks a lot in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
Partial function application (or currying) is the act of taking a function with two or more parameters, and applying some of the arguments in order to make a new function. The hello world example for this seems to be this: Let's say you have a function called `add`, that takes two parameters: def add(left, right): ... return left + right Now let's say you want a function that always adds 2 to a number you give it. You can use partial function application to do this: from functools import partial add2 = partial(add, right=2) Now, you have a new function, `add2`, that takes one parameter: add2(4) 6 --- Paul Woolcock pwool...@gmail.com On Mon, Jul 18, 2011 at 6:13 AM, Kurian Thayil kurianmtha...@gmail.com wrote: Hi, I am a newbie in python and would like to learn GUI programming. I would like to know what exactly is Partial Function Applicaton (functool.partial())? Or how is it advantageous compared to normal functions? Or is there any advantange? Thanks in advance. Regards, Kurian Thayil. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Aw: Re: Aw: Functional style programming in python: what will you talk about if you have an hour on this topic?
Thanks for all the great suggestion. First of all, Carl is right that it does not take much to impress a java programmer about the expressiveness of functional programming. Covered map, reduce and filter as Rainer suggested. Emphasized the advantages of functional style as summarised by Steve D'Aprano. I showcased the use of groupby() in itertools. Think about what it takes to implement similar logic in Java. Also introduced the gotcha of using groupby(): you must first sort the list in the same way you want to group them by. Then I got ambitious and tried to introduce partial(). I basically lost everyone right there. They can understand what partial does but do not know why it can be useful. My example was too trivial and it did not help. What is the best way to introduce partial/currying? -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. Keyboards??? That was a luxery! We had mechanical switches that one had to physically push and pull to enter commands. And a 40 column display??? Unheard of! We were happy with several miniature flashlight bulbs! But you try and tell the young people today that... and they won't believe ya'. Fond memories! Malcolm Ref: http://totallytrygve.com/computer.php?item=188picture=0 http://www.logikus.info/english.htm http://oldcomputermuseum.com/logix_kosmos.html http://www.classiccmp.org/pipermail/cctech/2007-October/086682.html http://www.computerhistory.org/collections/accession/102621921 http://www.classiccmp.org/dunfield/ (scanned manual) -- http://mail.python.org/mailman/listinfo/python-list
Running Python on a Computer Cluster in the Cloud - cloudnumbers.com
Dear Python users, cloudnumbers.com provides researchers and companies with the access to resources to perform high performance calculations in the cloud. As cloudnumbers.com's community manager I may invite you to register and test your Python application on a computer cluster in the cloud for free: http://my.cloudnumbers.com/register We are looking forward to get your feedback and consumer insights. Take the chance and have an impact to the development of a new cloud computing calculation platform. Our aim is to change the way of research collaboration is done today by bringing together scientists and businesses from all over the world on a single platform. cloudnumbers.com is a Berlin (Germany) based international high-tech startup striving for enabling everyone to benefit from the High Performance Computing related advantages of the cloud. We provide easy access to applications running on any kind of computer hardware from single core high memory machines up to 1000 cores computer clusters. To get more information check out our web-page (http://www.cloudnumbers.com/) or follow our blog about cloud computing, HPC and HPC applications: http://cloudnumbers.com/blog Key features of our platform for efficient computing in the cloud are: * Turn fixed into variable costs and pay only for the capacity you need. Watch our latest saving costs with cloudnumbers.com video: http://www.youtube.com/watch?v=ln_BSVigUhgfeature=player_embedded * Enter the cloud using an intuitive and user friendly platform. Watch our latest cloudnumbers.com in a nutshell video: http://www.youtube.com/watch?v=0ZNEpR_ElV0feature=player_embedded * Be released from ongoing technological obsolescence and continuous maintenance costs (e.g. linking to libraries or system dependencies) * Accelerated your Python, C, C++, Fortran, R, ... calculations through parallel processing and great computing capacity - more than 1000 cores are available and GPUs are coming soon. * Share your results worldwide (coming soon). * Get high speed access to public databases (please let us know, if your favorite database is missing!). * We have developed a security architecture that meets high requirements of data security and privacy. Read our security white paper: http://d1372nki7bx5yg.cloudfront.net/wp-content/uploads/2011/06/cloudnumberscom-security.whitepaper.pdf Best Markus -- Dr. rer. nat. Markus Schmidberger Senior Community Manager Cloudnumbers.com GmbH Chausseestraße 6 10119 Berlin www.cloudnumbers.com E-Mail: markus.schmidber...@cloudnumbers.com * Amtsgericht München, HRB 191138 Geschäftsführer: Erik Muttersbach, Markus Fensterer, Moritz v. Petersdorff-Campen -- http://mail.python.org/mailman/listinfo/python-list
RE: Ordered list question
Can you share a website that goes into more detail on this good variable naming? I'd Google that one. You'll find more articles than you can read in a lifetime... Very true! :-) -- http://mail.python.org/mailman/listinfo/python-list
planet.python.org blog registration
Hello, whom I have to contact to get a blog aggregated in planet.python.org? Thanks Markus -- http://mail.python.org/mailman/listinfo/python-list
Re: planet.python.org blog registration
On 07/18/2011 03:04 PM, Markus Schmidberger wrote: Hello, whom I have to contact to get a blog aggregated in planet.python.org? Thanks Markus I quote planet.python.org (below the list of names) To request addition or removal: e-mail planet at python.org (note, responses can take up to a few days) -- http://mail.python.org/mailman/listinfo/python-list
Re: open urls in browser
On Mon, Jul 18, 2011 at 10:05 PM, srikanth srikanth0...@gmail.com wrote: Ex: http://www.google.com - Pass/Fail. What do you mean by Pass or Fail? If you send a URL to a web browser, all you'll find out is whether or not the browser accepted it - it won't tell you if the page is valid. If you want that, you don't need a web browser at all - what you want is a simple URL fetcher, such as urllib/urllib2. http://docs.python.org/library/urllib.html http://docs.python.org/release/3.1.3/library/urllib.request.html ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: open urls in browser
On Jul 18, 6:21 pm, Chris Angelico ros...@gmail.com wrote: On Mon, Jul 18, 2011 at 10:05 PM, srikanth srikanth0...@gmail.com wrote: Ex:http://www.google.com- Pass/Fail. What do you mean by Pass or Fail? If you send a URL to a web browser, all you'll find out is whether or not the browser accepted it - it won't tell you if the page is valid. If you want that, you don't need a web browser at all - what you want is a simple URL fetcher, such as urllib/urllib2. http://docs.python.org/library/urllib.htmlhttp://docs.python.org/release/3.1.3/library/urllib.request.html ChrisA Sorry i don't need that one. by mistake i have written it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Argparse, and linking to methods in Subclasses
Hello Michele, Your solution is great! You can combine it perhaps with the use of set_defaults() method of the argparse parser, I gave. Cheers karim On 07/18/2011 01:56 PM, Michele Simionato wrote: Here is an example by using my own library plac (http://pypi.python.org/pypi/plac): class Server(): def configure_logging(self, logging_file): pass def check(self): pass def deploy(self): pass def configure(self): pass def __init__(self, hostname): self.hostname = hostname class SpamServer(Server): def check(self): pass class HamServer(Server): def deploy(self): pass def main(classname, hostname, methname): # add error checking at will instance = globals()[classname](hostname) getattr(instance, methname)() if __name__ == '__main__': import plac; plac.call(main) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Tim Chase python.l...@tim.thechases.com wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. Acorn System One: 9 character 7 segment led display and 25 key keypad, 1Kb RAM, 512 bytes ROM. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Jul 17, 12:47 am, Xah Lee xah...@gmail.com wrote: 2011-07-16 folks, this one will be interesting one. the problem is to write a script that can check a dir of text files (and all subdirs) and reports if a file has any mismatched matching brackets. … Ok, here's my solution (pasted at bottom). I haven't tried to make it elegant or terse, yet, seeing that many are already much elegent than i could possibly do so with my code. my solution basically use a stack. (i think all of us are doing similar) Here's the steps: • Go thru the file char by char, find a bracket char. • check if the one on stack is a matching opening char. If so remove it. Else, push the current onto the stack. • Repeat the above till end of file. • If the stack is not empty, then the file got mismatched brackets. Report it. • Do the above on all files. Many elegant solutions. Raymond Hettinger is very quick, posted a solution only after a hour or so when i posted it. Many others are very short, very nice. Thank you all for writing them. I haven't studied them yet. I'll run them all and post a summary in 2 days. (i have few thousands files to run this test thru, many of them have mismatched brackets. So i have good data to test with.) PS we still lack a perl, Scheme lisp, tcl, lua versions. These wouldn't be hard and would be interesting to read. If you are picking up one of these lang, this would be a good exercise. Haskell too. I particularly would like to see a javascript version ran from command line. Maybe somebody can put this exercise to Google folks ... they are like the js gods. also, now that we have these home-brewed code, how'd a parser expert do it? Is it possible to make it even simpler by using some parser tools? (have no idea what those lex yacc do, or modern incarnations) I've also been thinking whether this can be done with Parsing Expression Grammar. That would make the code semantics really elegant (as opposed home-cooked stack logic). Xah ;; -*- coding: utf-8 -*- ;; 2011-07-15, Xah Lee ;; go thru a file, check if all brackets are properly matched. ;; e.g. good: (…{…}… “…”…) ;; bad: ( [)] ;; bad: ( ( ) (setq inputDir ~/web/xahlee_org/p/) ; must end in slash (defvar matchPairs '() a alist. For each air, the car is opening char, cdr is closing char.) (setq matchPairs '( (( . )) ({ . }) ([ . ]) (“ . ”) (‹ . ›) (« . ») (【 . 】) (〈 . 〉) (《 . 》) (「 . 」) (『 . 』) ) ) (defvar searchRegex regex string of all pairs to search.) (setq searchRegex ) (mapc (lambda (mypair) (setq searchRegex (concat searchRegex (regexp-quote (car mypair)) | (regexp-quote (cdr mypair)) |) ) ) matchPairs) (setq searchRegex (replace-regexp-in-string |$ searchRegex t t)) ; remove the ending “|” (setq searchRegex (replace-regexp-in-string | \\| searchRegex t t)) ; change | to \\| for regex “or” operation (defun my-process-file (fpath) process the file at fullpath fpath ... (let (myBuffer (ii 0) myStack ξchar ξpos) (setq myStack '() ) ; each element is a vector [char position] (setq ξchar ) (setq myBuffer (get-buffer-create myTemp)) (set-buffer myBuffer) (insert-file-contents fpath nil nil nil t) (goto-char 1) (while (search-forward-regexp searchRegex nil t) (setq ξpos (point) ) (setq ξchar (buffer-substring-no-properties ξpos (- ξpos 1)) ) ;; (princ (format -\nfound char: %s \n ξchar) ) (let ((isClosingCharQ nil) (matchedOpeningChar nil) ) (setq isClosingCharQ (rassoc ξchar matchPairs)) (when isClosingCharQ (setq matchedOpeningChar (car isClosingCharQ) ) ) ;; (princ (format isClosingCharQ is: %s\n isClosingCharQ) ) ;; (princ (format matchedOpeningChar is: %s\n matchedOpeningChar) ) (if (and (car myStack) ; not empty (equal (elt (car myStack) 0) matchedOpeningChar ) ) (progn ;; (princ (format matched this bottom item on stack: %s \n (car myStack)) ) (setq myStack (cdr myStack) ) ) (progn ;; (princ (format did not match this bottom item on stack: %s\n (car myStack)) ) (setq myStack (cons (vector ξchar ξpos) myStack) ) ) ) ) ;; (princ current stack: ) ;; (princ myStack ) ;; (terpri ) ) (when (not (equal myStack nil)) (princ Error file: ) (princ fpath) (print (car myStack) ) ) (kill-buffer myBuffer) )) ;; (require 'find-lisp) (let (outputBuffer) (setq outputBuffer *xah match pair output* ) (with-output-to-temp-buffer outputBuffer (mapc 'my-process-file (find-lisp-find-files inputDir \\.html$)) (princ Done deal!) ) ) --
Re: Tabs -vs- Spaces: Tabs should have won.
Tim Chase wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. 40 columns? Luxury! My first computer was a Hewlett Packard 28S handheld programmable calculator, with 22 columns[1] and 32 entire kilobytes of memory! (I don't include my previous programmable calculator, a Casio, or was it a Canon, as the programming language included wasn't Turing Complete.) [1] I think it was 22 columns -- that's what my HP 48GX has, and I'm sure the 28S screen was no larger. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Recommendations for household finance scripting?
Hello! I would like to find a good system to keep track of my household finance. Do Python programmers have suggestions on that? Do you use Python to help on this task? I am considering a large set of solutions: - Pure spreadsheet - Easy to start, but I know I will soon feel blocked by the lack of scripting tools. - Spreadsheets + Python scripts - Enter data in spreadsheets, next apply python scripts for what is difficult to do with formulas - Use pythonUNO (http://wiki.services.openoffice.org/wiki/ PyUNO_bridge)? - Use Google spreadsheets api (http://code.google.com/apis/ spreadsheets/)? - Pure Gnucash - Seems to be a nice program, made by geeks. - But can a geek be happy with a GUI between him and his data? - Gnucash + Python scripts - http://current.workingdirectory.net/posts/2011/gnucash-python-bindings/ So far the last one seems to me to be the most interesting approach. Apparently there are not many people doing that. Why? Are there other libs or approaches you would suggest? Thanks a lot in advance for your suggestions and comments! Marko -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
Kurian Thayil wrote: Hi, I am a newbie in python and would like to learn GUI programming. I would like to know what exactly is Partial Function Applicaton (functool.partial())? Or how is it advantageous compared to normal functions? Or is there any advantange? Thanks in advance. It is mostly for functional programming style. But one lucky side-effect of the implementation is that partial functions *may* sometimes be faster than the alternative written in pure Python, provided the original function is written in C: from functools import partial from operator import add def add_one(x): return add(1, x) # Like 1+x add_two = partial(add, 2) from timeit import Timer setup = from __main__ import add_one, add_two t1 = Timer(add_one(42), setup) t2 = Timer(add_two(42), setup) And in action: t1.timeit() 0.7412619590759277 t2.timeit() 0.3557558059692383 So in this example, the partial function is about twice as fast as the one written in Python. This does not necessarily apply for all functions, but it sometimes is useful. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommendations for household finance scripting?
On Jul 18, 8:03 pm, markolopa marko.lopa...@gmail.com wrote: Hello! I would like to find a good system to keep track of my household finance. Do Python programmers have suggestions on that? Do you use Python to help on this task? I am considering a large set of solutions: - Pure spreadsheet - Easy to start, but I know I will soon feel blocked by the lack of scripting tools. - Spreadsheets + Python scripts - Enter data in spreadsheets, next apply python scripts for what is difficult to do with formulas - Use pythonUNO (http://wiki.services.openoffice.org/wiki/ PyUNO_bridge)? - Use Google spreadsheets api (http://code.google.com/apis/ spreadsheets/)? - Pure Gnucash - Seems to be a nice program, made by geeks. - But can a geek be happy with a GUI between him and his data? - Gnucash + Python scripts -http://current.workingdirectory.net/posts/2011/gnucash-python-bindings/ So far the last one seems to me to be the most interesting approach. Apparently there are not many people doing that. Why? Are there other libs or approaches you would suggest? Thanks a lot in advance for your suggestions and comments! Marko There is ledger http://ledger-cli.org/ And its python port https://github.com/jwiegley/beancount [Not tried myself] -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On Monday, July 18, 2011 09:32:19 AM Tim Chase did opine: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. -tkc (expecting somebody to come back with a bit more retro-computing Four Yorkshiremen bit...spinning 360k 5.25 floppy drives? We should be so lucky. I had to hand jump 2000-amp bits with only my tongue, for a CPU architecture invented by Navajo code-talkers...) No, but my first computer was an RCA Cosmac Super Elf, with a 6 digit led display. I added another 4k of static ram ($400 for the s100 board kit, and about $100 for the S-100 4 slot backplane, and about $125 for a cash register style cabinet that I hid the rest of the hardware, including a 6 volt gell cell for backup battery in) This had an RCA 1802 CPU which had a very interesting architecture. Writing, in machine code entered through its monitor, a program that drove the rest of the hardware and connected to the remote controls of the U- Matic tape machines of the day, including the display hardware I built from scratch with mostly TTL parts, it was replacing the most labor intensive step in preparing a commercial for use with an Automatic station break machine by applying a new frame accurate academy leader and the tones to control it directly to the finished commercial tape. That automated a very timing critical step, and removed a dub cycle from commercial production at KRCR in 1979, and was still in use in 1994 the last time I checked. How many of our code projects can make that claim? I still have a paper copy of the code in a bag on the top shelf. Interesting sidelight here. In 1980, Microtime brought a much more primative device to do that to the NAB show, which I stopped and looked at, and when I could control my laughing, said I had already done that, functionally far better than this attempt. Since they are as lawyer top loaded as Apple, I guess they assumed I had also copyrighted and patented it, so it was gone the next day they wouldn't even admit they had had it the day before. In 1987 I made a better version of the EDISK that Grass Valley sold as an accessory for the 300 series video production switchers, for $20,000. Theirs had a 2 digit display for file names ran at 1200 baud. Mine had a whopping 32 column display and english filenames and ran at 4800 baud, running on a TRS-80 Color Computer, I had $245 in the hardware. It was still in use when I retired in 2002, but when that forced a replacement of the 300 because of custom parts availability, the new CE gave me back the old machine. I still have it, and several more of them. The 6809 was not the crippled, drain bamaged processor the 6502 was. OS-9, the color computers multiuser/multitasking OS, has now grown to also execute on the hitachi 6309 cpu chip, and is about 2x faster now than then, and we now call it Nitros9. That is essentially todays linux, running on an 8 bit bus, and was my teacher, causing me to only have one legal winderz install in the house ever as it was on the laptop (XP) I bought quite a few years back now. Long since history, that machine has had linux on it for about 6 years now. FWIW, I met one of the code talkers when I was the CE at KIVA-TV in the late 70's. That was another example of how we have screwed the First Americans' and I had better not get started. Cheers, gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) Beneath this stone lies Murphy, They buried him today, He lived the life of Riley, While Riley was away. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Thorsten Kampe thors...@thorstenkampe.de writes: The perfect programming font is just the one that looks so good that you would also use it for writing email. Dejavu Sans Mono is pretty good. Consolas looks also looks good but it is Windows only. How is Consolas Windows only? Not that I'd put it in my Windows-free systems, but I don't see why you couldn't? Everything uses TrueType fonts now. I use a font called Dina on this laptop in Emacs. Not pretty but very readable, has a slashed zero and the wide characters are clearly separated, so something like www looks like three ws, not a block of triangle wave. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Rouslan Korneychuk wrote: I don't know why, but I just had to try it (even though I don't usually use Perl and had to look up a lot of stuff). I came up with this: I don't know why … you replied to my posting/e-mail (but quoted nothing from it, much less referred to its content), and posted a lot of Perl code in a Python newsgroup/on a Python mailing list. -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
* Anssi Saari (Mon, 18 Jul 2011 19:28:49 +0300) Thorsten Kampe thors...@thorstenkampe.de writes: The perfect programming font is just the one that looks so good that you would also use it for writing email. Dejavu Sans Mono is pretty good. Consolas looks also looks good but it is Windows only. How is Consolas Windows only? Not that I'd put it in my Windows-free systems, but I don't see why you couldn't? Consolas ships with all versions of Windows Vista and Windows 7, including Home Basic. If you’re using Visual Studio 2005, you can download Consolas from Microsoft. If not, you still may be able to use the font, though your mileage may vary. I was able to install it on a Windows XP SP1 machine that doesn’t have any version of Visual Studio. This PC does have the Microsoft .NET Framework SDK which creates various “Microsoft Visual Studio” folders under “Program Files”. These may cause the Consolas installer to think I do have VS 2005. I got no error messages, and the font was instantly available in all applications. Another way to get Consolas is to download and install the free PowerPoint Viewer 2007 from Microsoft. This works on any computer with Windows 2000 SP4 or Windows XP SP1 or later. In addition to the PowerPoint Viewer 2007 itself, the installer will install the following fonts: Calibri, Cambria, Candara, Consolas, Constantia and Corbel. Only the Consolas font is monospaced. All these fonts ship with Windows Vista and Windows 7. http://www.editpadpro.com/fonts.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On 18/07/2011 14:52, Duncan Booth wrote: Tim Chasepython.l...@tim.thechases.com wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. Acorn System One: 9 character 7 segment led display and 25 key keypad, 1Kb RAM, 512 bytes ROM. 1KB RAM? Wow! Science of Cambridge Mk14, with extra RAM and I/O chip, total of 640 bytes (some reserved for monitor program). Main RAM at 0xF00..0xFFF, extra RAM at 0xB00..0xBFF, I/O RAM somewhere else... -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Gregory Ewing wrote: Anders J. Munch wrote: Cameron Simpson wrote: Personally, I like to use the tab _key_ as an input device, but to have my editor write real spaces to the file in consequence. Just like in the old days:) Most editors can be configured to do that. True. Where they fall down, in my experience, is that having inserted those spaces, if you want to delete them you typically have to backspace over them one at a time. Now that's a BAD source code editor! Try one running on the Eclipse platform, like PyDev (single plugin or in Aptana, also as Eclipse plugin). But, even vim(1) has auto-indent *and* `', so … I don't enjoy that experience, which is why I have BBEdit Lite set up to use tab-only indentation. If I'm feeling conscientious, I convert to spaces before sharing the code with others. But tabs work better for me given the tools I use and the way I like to work. YMMV, of course. -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Anssi Saari wrote: Thorsten Kampe thors...@thorstenkampe.de writes: The perfect programming font is just the one that looks so good that you would also use it for writing email. Dejavu Sans Mono is pretty good. Consolas looks also looks good but it is Windows only. How is Consolas Windows only? Not that I'd put it in my Windows-free systems, but I don't see why you couldn't? Consolas is _not_ free software, hence Inconsolata which is. Windows-only is too strong a classification for Consolas, though. Everything uses TrueType fonts now. Rather OpenType, but that is beside the point. -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On 01/-10/-28163 02:59 PM, Steven D'Aprano wrote: Tim Chase wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. 40 columns? Luxury! My first computer was a Hewlett Packard 28S handheld programmable calculator, with 22 columns[1] and 32 entire kilobytes of memory! (I don't include my previous programmable calculator, a Casio, or was it a Canon, as the programming language included wasn't Turing Complete.) [1] I think it was 22 columns -- that's what my HP 48GX has, and I'm sure the 28S screen was no larger. My first programmable calculator had 1.5k of RAM, display was 13 digits wide, and it took an optional 2k of PROM via a plugin socket on top. I wrote a commercially sold navigation program for that calculator. The program was used on ships in 1974 and later. Later I squeezed the code a bit and made room for a dead reckoning program and great circle calculator. I didn't write a cross assembler for it till after this project was finished. That assembler ran on a machine with 64 column display. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. import sys, os pairs = {'}':'{', ')':'(', ']':'[', '':'', ':', '':''} valid = set( v for pair in pairs.items() for v in pair ) for dirpath, dirnames, filenames in os.walk(sys.argv[1]): for name in filenames: stack = [' '] with open(os.path.join(dirpath, name), 'rb') as f: chars = (c for line in f for c in line if c in valid) for c in chars: if c in pairs and stack[-1] == pairs[c]: stack.pop() else: stack.append(c) print (Good if len(stack) == 1 else Bad) + ': %s' % name -- Bill -- http://mail.python.org/mailman/listinfo/python-list
AUTO: Craig Churchill is out of the office (returning 27/07/2011)
I am out of the office until 27/07/2011. I will respond to your message when I return. If you require assitance in relation to the SPEAR Integration project please contact Terry Mandalios. Note: This is an automated response to your message Re: Tabs -vs- Spaces: Tabs should have won. sent on 19/7/2011 2:59:19. This is the only notification you will receive while this person is away. Notice: This email and any attachments may contain information that is personal, confidential, legally privileged and/or copyright.No part of it should be reproduced, adapted or communicated without the prior written consent of the copyright owner. It is the responsibility of the recipient to check for and remove viruses. If you have received this email in error, please notify the sender by return email, delete it from your system and destroy any copies. You are not authorised to use, communicate or rely on the information contained in this email. Please consider the environment before printing this email. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Mon, Jul 18, 2011 at 11:12 AM, Billy Mays 81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com wrote: I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Uh, okay... Your script also misses the requirement of outputting the index or row and column of the first mismatched bracket. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 07/18/2011 12:46 PM, Thomas 'PointedEars' Lahn wrote: Rouslan Korneychuk wrote: I don't know why, but I just had to try it (even though I don't usually use Perl and had to look up a lot of stuff). I came up with this: I don't know why … you replied to my posting/e-mail (but quoted nothing from it, much less referred to its content), and posted a lot of Perl code in a Python newsgroup/on a Python mailing list. Well, when I said I had to try *it*, I was referring to using a Perl compatible regular expression, which you brought up. I guess I should have quoted that part. As for what I posted, the crux of it was a single regular expression. The Perl code at the bottom was just to point out that I didn't type that monstrosity out manually. I was going to put that part in brackets but there were already so many. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Thomas 'PointedEars' Lahn wrote: I am getting the idea here that you mean the right thing, but that you explain it wrong. Feel free to write the much longer essay that explains it all unambiguously, I'm not going to. regards, Anders -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On Mon, Jul 18, 2011 at 02:55, Andrew Berg I think the reason the idea isn't dead is because of the emergence of new devices with small displays (tablets/smartphones/etc.) and their increasing popularity. When writing code that is meant to be run on desktops or servers, the 80-column limit is mostly irrelevant, but Python running on these small devices, especially with Python code being interpreted rather than compiled, it's convenient to edit code on those platforms, where there is a significant column limit. Let me see if I understand: because there exists a possibility that someone might want (not need) to edit code on a telephone to make a quick edit to code being interpreted on that machine, _all_ Python code should limit itself to a line width that may or may not wrap on a telephone screen? Is that the argument in favor of an 80-character line width? -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 On 2011.07.18 01:51 PM, Dotan Cohen wrote: Let me see if I understand: because there exists a possibility that someone might want (not need) to edit code on a telephone to make a quick edit to code being interpreted on that machine, _all_ Python code should limit itself to a line width that may or may not wrap on a telephone screen? Is that the argument in favor of an 80-character line width? I doubt that's /the/ argument. I speculated that it's one of the reasons that a column limit still has relevance. I did not say that I thought the argument had merit; I make no judgment either way. Also, I'm sure more than quick edits are done on these phones. Depending on the focus of the project, it may be best to do most, if not all testing on that device. Personally, I think that 80 is pretty arbitrary now, and not the best limit. I'm more comfortable with 120-130 myself. In any case, Python won't complain about how many characters are on a line, and that's the way it should be. - -- CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0 PGP/GPG Public Key ID: 0xF88E034060A78FCB -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAwAGBQJOJIQ9AAoJEPiOA0Bgp4/LhgUH/iFWmSZXw9Rw0SyHpRZ4gPvb WahJhf3j0bAnWnJWueAMgzgTMzuZv/6V6x8Yka/KewjBk5/coIsCNHgL+LR8rrat YbN3FTQneuTlwtkj+2wQV+pQEQM6i2eVs50TEji98NW1jqtwW3UxhT/x4efaUHtc 9iHZRZTqmNMlXJWfRgfD6mC0bHGGAUTadyetGHicdZYy+AIo8Di7tObd5SwuQxIM 8U7aRkupiOpRaUj3YXXsIuWeio+SirpnJiVdWadBbgsdBSjI8jJl2MqXq52BieA6 5avnDGA+6575+1GNTaLXHNyFpgNkTUXCb5cOf3TP6zk0q9EtNxYY9dxQ8QJmdU8= =sKG0 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
On Tue, Jul 19, 2011 at 5:06 AM, Andrew Berg bahamutzero8...@gmail.com wrote: Personally, I think that 80 is pretty arbitrary now, and not the best limit. I'm more comfortable with 120-130 myself. In any case, Python won't complain about how many characters are on a line, and that's the way it should be. It's a question of policy, which is in the purview of the maintainer of the codebase. But since Python itself has a lot of Python code, the policy applied to its standard library is going to be looked at by everyone as having special status. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: AUTO: Craig Churchill is out of the office (returning 27/07/2011)
I am out of the office until 27/07/2011. I will respond to your message when I return. If you require assitance in relation to the SPEAR Integration project please contact Terry Mandalios. Why, thank you Craig. I will definitely contact Terry ;-) Br. Waldek PS. Sorry, couldn't stop myself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
Partial can be used in a GUI program, like Tkinter, to send arguments to functions. There are other ways to do that as well as using partial. The following program uses partial to send the color to the change_buttons function. from Tkinter import * from functools import partial class App: def __init__(self, parent): self.my_parent = parent self.my_parent.geometry(200x100+10+10) self.R = list() for ctr, color in enumerate((Red, Blue, Green)): btn = Radiobutton(self.my_parent, text=color, value=ctr+1, command=partial(self.change_buttons, color)) btn.grid(row = 2, column = ctr+1) btn.deselect() self.R.append(btn) self.R[0].select() self.change_buttons(Red) def change_buttons(self, color): self.my_parent.configure(bg=color) for btn in self.R: btn.configure(bg=color) if __name__ == __main__: root = Tk() root.title (Color Option) app = App(root) root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ?
On Sun, 17 Jul 2011 00:47:42 -0700 (PDT), Xah Lee xah...@gmail.com wrote: 2011-07-16 folks, this one will be interesting one. the problem is to write a script that can check a dir of text files (and all subdirs) and reports if a file has any mismatched matching brackets. [snip] i hope you'll participate. Just post solution here. Thanks. I have to hunt for a job so I'm not writing a solution for you. Here is a thin regex framework that may get you started. -sln - use strict; use warnings; my @samples = qw( A98(y[(np)r]x)tp[kk]a.exeb A98(y[(np)r]x)tp[kk]a}.exeb A98(ynprx)tpkka.mpeg A98(ynprx)tpkka A9«8(yn«pr{{[g[x].}*()+}»)tpkka». A9«8(yn«pr{{[g[x].]}*()+}»)tpkka». A9«8(yn«pr»)tpkka». A9«8(yn«pr»)»t(()){}[a[b[d]{}]pkka.]«**^{[()]}» A9«8(yn«pr»)t(()){}[a[b[d]{}]pkka.]«**^{[()]}» ); my $regex = qr/ ^ (?FileName) $ (?(DEFINE) (?Delim \( (?Content) \) | \{ (?Content) \} | \[ (?Content) \] | \ (?Content) \ | \ (?Content) \ | \« (?Content) \» # add more here .. ) (?Content (?: (? [^(){}\[\]«»]+ ) # add more here .. | (?Delim) )* ) (?FileName (?Content) ) ) /x; for (@samples) { print $_ - ; if ( /$regex/ ) { print passed \n; } else { print failed \n; } } __END__ Output: A98(y[(np)r]x)tp[kk]a.exeb - passed A98(y[(np)r]x)tp[kk]a}.exeb - failed A98(ynprx)tpkka.mpeg - failed A98(ynprx)tpkka - passed A9«8(yn«pr{{[g[x].}*()+}»)tpkka». - failed A9«8(yn«pr{{[g[x].]}*()+}»)tpkka». - passed A9«8(yn«pr»)tpkka». - passed A9«8(yn«pr»)»t(()){}[a[b[d]{}]pkka.]«**^{[()]}» - passed A9«8(yn«pr»)t(()){}[a[b[d]{}]pkka.]«**^{[()]}» - failed -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for general advice on complex program
That would be one of mine, probably. http://code.google.com/p/pyxmlcheck/ It's an old version. I haven't updated it in a while. And while my program worked fine at home, my test environment gave me some grief. Apparently the lock files are being deleted properly. I have a few ideas about that, but I'm away from my code right now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
On 7/18/2011 8:24 AM, Paul Woolcock wrote: Partial function application (or currying) is the act of taking a function with two or more parameters, and applying some of the arguments in order to make a new function. The hello world example for this seems to be this: Let's say you have a function called `add`, that takes two parameters: def add(left, right): ... return left + right Now let's say you want a function that always adds 2 to a number you give it. You can use partial function application to do this: from functools import partial add2 = partial(add, right=2) Now, you have a new function, `add2`, that takes one parameter: add2(4) Or you can directly write def add2(x): return x + 2 or more generically def makeadder(y) def _add(x): return x+y add2 = makeadder(2) functool.partial is essential a generic version of makeadder in that it also abstract the function/operator. It is useful when one has a function but perhaps not the source. It's limitation is that args are frozen left to right while the above example freezes the right operand. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Aw: Re: Aw: Functional style programming in python: what will you talk about if you have an hour on this topic?
On 7/18/2011 8:20 AM, Anthony Kong wrote: Thanks for all the great suggestion. First of all, Carl is right that it does not take much to impress a java programmer about the expressiveness of functional programming. Covered map, reduce and filter as Rainer suggested. Emphasized the advantages of functional style as summarised by Steve D'Aprano. I showcased the use of groupby() in itertools. Think about what it takes to implement similar logic in Java. Also introduced the gotcha of using groupby(): you must first sort the list in the same way you want to group them by. Then I got ambitious and tried to introduce partial(). I basically lost everyone right there. They can understand what partial does but do not know why it can be useful. My example was too trivial and it did not help. What is the best way to introduce partial/currying? See my response to Kurian -- Partial Function Application -- just a few minutes ago. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
On 7/18/2011 3:23 PM, woooee wrote: Partial can be used in a GUI program, like Tkinter, to send arguments to functions. There are other ways to do that as well as using partial. The following program uses partial to send the color to the change_buttons function. from Tkinter import * from functools import partial class App: def __init__(self, parent): self.my_parent = parent self.my_parent.geometry(200x100+10+10) self.R = list() for ctr, color in enumerate((Red, Blue, Green)): btn = Radiobutton(self.my_parent, text=color, value=ctr+1, command=partial(self.change_buttons, color)) btn.grid(row = 2, column = ctr+1) This is a nice illustration. For future reference: enumerate now takes a start value as second parameter. Given as 1, you do not need to remember to add 1 for each usage. for ctr, color in enumerate((Red, Blue, Green),1): btn = Radiobutton(self.my_parent, text=color, value=ctr, command=partial(self.change_buttons, color)) btn.grid(row = 2, column = ctr) btn.deselect() self.R.append(btn) self.R[0].select() self.change_buttons(Red) def change_buttons(self, color): self.my_parent.configure(bg=color) for btn in self.R: btn.configure(bg=color) if __name__ == __main__: root = Tk() root.title (Color Option) app = App(root) root.mainloop() -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Crazy what-if idea for function/method calling syntax
On 18 juil, 07:54, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Mon, 18 Jul 2011 08:54 am ΤΖΩΤΖΙΟΥ wrote: Jumping in: What if a construct xx(*args1, **kwargs1)yy(*args2, **kwargs2) was interpreted as xxyy(*(args1+args2), **(kwargs1+kwargs2)) (Note: with **(kwargs1+kwargs2) I mean “put keyword arguments in the order given”, since dicts can't be added) This construct is currently a syntax error. The intent of this idea is to help improve legibility. I don't think it does that. I think it is misleading, as it looks like two independent function calls. It also makes it hard to search for a function call -- instead of searching for do_something\(.*\) you have to now search for do_something\(.*\) do\(.*\)_something\(.*\) do_\(.*\)something\(.*\) do_some\(.*\)thing\(.*\) and so on. Example: def place_at(item, x, y): blah blah could be called as place(item)_at(x, y) You would probably like the Xtalk family of languages, starting with Hypertalk from Apple in the late 80s or early 90s. There's a neat implementation here:http://code.google.com/p/openxion/ Xtalk includes syntax like this: put newStr into character 23 to 42 of theStr put suffix after theStr delete first char of theStr although this only applied to built-in functions, not user-functions. -- Steven If I understand correctly, you propose to translate do something to X with arguments a,b,c to (1) do_something_to(X)_with_arguments(a,b,c) instead of (2) do_something(X,a,b,c) I agree that the first one is more readable than the second, because in the arguments list in (2) you mix the object you are working on and the parameters used. But there is another option : (3) X.do_something_with_arguments(a,b,c) which would be in your examples : item.place_at(x,y) or iterable.group_by(collection) It's valid Python code and probably as readable than what you suggest, with a clear distinction between the object and the arguments - Pierre -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
On 01/-10/-28163 02:59 PM, Terry Reedy wrote: On 7/18/2011 8:24 AM, Paul Woolcock wrote: Partial function application (or currying) is the act of taking a function with two or more parameters, and applying some of the arguments in order to make a new function. The hello world example for this seems to be this: snip def makeadder(y) def _add(x): return x+y add2 = makeadder(2) snip A couple of typos in that code: def makeaddr(y): def _add(x): return x+y return _add DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Ian Kelly wrote: Billy Mays wrote: I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Uh, okay... Your script also misses the requirement of outputting the index or row and column of the first mismatched bracket. Thanks to Python's expressiveness, this can be easily remedied (see below). I also do not follow Billy's comment about Unicode. Unicode and the fact that Python supports it *natively* cannot be appreciated enough in a globalized world. However, I have learned a lot about being pythonic from his posting (take those generator expressions, for example!), and the idea of looking at the top of a stack for reference is a really good one. Thank you, Billy! Here is my improvement of his code, which should fill the mentioned gaps. I have also reversed the order in the report line as I think it is more natural this way. I have tested the code superficially with a directory containing a single text file. Watch for word-wrap: # encoding: utf-8 ''' Created on 2011-07-18 @author: Thomas 'PointedEars' Lahn pointede...@web.de, based on an idea of Billy Mays 81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com in news:j01ph6$knt$1...@speranza.aioe.org ''' import sys, os pairs = {u'}': u'{', u')': u'(', u']': u'[', u'”': u'“', u'›': u'‹', u'»': u'«', u'】': u'【', u'〉': u'〈', u'》': u'《', u'」': u'「', u'』': u'『'} valid = set(v for pair in pairs.items() for v in pair) if __name__ == '__main__': for dirpath, dirnames, filenames in os.walk(sys.argv[1]): for name in filenames: stack = [' '] # you can use chardet etc. instead encoding = 'utf-8' with open(os.path.join(dirpath, name), 'r') as f: reported = False chars = ((c, line_no, col) for line_no, line in enumerate(f) for col, c in enumerate(line.decode(encoding)) if c in valid) for c, line_no, col in chars: if c in pairs: if stack[-1] == pairs[c]: stack.pop() else: if not reported: first_bad = (c, line_no + 1, col + 1) reported = True else: stack.append(c) print '%s: %s' % (name, (good if len(stack) == 1 else bad '%s' at %s:%s % first_bad)) -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
Dave Angel wrote: On 01/-10/-28163 02:59 PM, Terry Reedy wrote: def makeadder(y) def _add(x): return x+y add2 = makeadder(2) A couple of typos in that code: def makeaddr(y): def _add(x): return x+y return _add I agree about the `return' statement, but not about the factory name; this has nothing to do with addresses (addr). -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Partial Function Application -- Advantages over normal function?
Thomas 'PointedEars' Lahn wrote: Dave Angel wrote: On 01/-10/-28163 02:59 PM, Terry Reedy wrote: def makeadder(y) def _add(x): return x+y add2 = makeadder(2) A couple of typos in that code: def makeaddr(y): def _add(x): return x+y return _add I agree about the `return' statement, but not about the factory name; this has nothing to do with addresses (addr). Supplemental: The above can be simplified to def makeadder(y): return lambda x: x + y -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
In article Xns9F2695C6AAA73duncanbooth@127.0.0.1, Duncan Booth duncan.booth@invalid.invalid wrote: Tim Chase python.l...@tim.thechases.com wrote: On 07/17/2011 08:01 PM, Steven D'Aprano wrote: Roy Smith wrote: We don't have that problem any more. It truly boggles my mind that we're still churning out people with 80 column minds. I'm willing to entertain arguments about readability of long lines, but the idea that there's something magic about 80 columns is hogwash. I agree! Which is why I set my line width to 78 columns. Bah, when I started programming on the Apple ][+, we had no lower-case and a 40-column limit on the TV display. But you try and tell the young people today that... and they won't believe ya'. Acorn System One: 9 character 7 segment led display and 25 key keypad, 1Kb RAM, 512 bytes ROM. HP-9810. http://www.hpmuseum.org/98xx/9810n3qs.jpg. BTW, if anybody has one of these in working condition that they want to get rid of, let me know. I'd love to play with one again. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Billy Mays wrote: On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Goobers... that would be one of those new-fangled slang terms that the young kids today use to mean its opposite, like bad, wicked and sick, correct? I mention it only because some people might mistakenly interpret your words as a childish and feeble insult against the 98% of the world who want or need more than the 127 characters of ASCII, rather than understand you meant it as a sign of the utmost respect for the richness and diversity of human beings and their languages, cultures, maths and sciences. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 7/18/2011 7:56 PM, Steven D'Aprano wrote: Billy Mays wrote: On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Goobers... that would be one of those new-fangled slang terms that the young kids today use to mean its opposite, like bad, wicked and sick, correct? I mention it only because some people might mistakenly interpret your words as a childish and feeble insult against the 98% of the world who want or need more than the 127 characters of ASCII, rather than understand you meant it as a sign of the utmost respect for the richness and diversity of human beings and their languages, cultures, maths and sciences. TL;DR version: international character sets are a problem, and Unicode is not the answer to that problem). As long as I have used python (which I admit has only been 3 years) Unicode has never appeared to be implemented correctly. I'm probably repeating old arguments here, but whatever. Unicode is a mess. When someone says ASCII, you know that they can only mean characters 0-127. When someone says Unicode, do the mean real Unicode (and is it 2 byte or 4 byte?) or UTF-32 or UTF-16 or UTF-8? When using the 'u' datatype with the array module, the docs don't even tell you if its 2 bytes wide or 4 bytes. Which is it? I'm sure that all the of these can be figured out, but the problem is now I have to ask every one of these questions whenever I want to use strings. Secondly, Python doesn't do Unicode exception handling correctly. (but I suspect that its a broader problem with languages) A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF, but you already knew that, as well as everyone else who wants to use strings for some reason). When embedding Python in a long running application where user input is received, it is very easy to make mistake which bring down the whole program. If any user string isn't properly try/excepted, a user could craft a malformed string which a UTF-8 decoder would choke on. Using ASCII (or whatever 8 bit encoding) doesn't have these problems since all codepoints are valid. Another (this must have been a good laugh amongst the UniDevs) 'feature' of unicode is the zero width space (UTF-8 code point 0xE2 0x80 0x8B). Any string can masquerade as any other string by placing few of these in a string. Any word filters you might have are now defeated by some cheesy Unicode nonsense character. Can you just just check for these characters and strip them out? Yes. Should you have to? I would say no. Does it get better? Of course! international character sets used for domain name encoding use yet a different scheme (Punycode). Are the following two domain names the same: tést.com , xn--tst-bma.com ? Who knows! I suppose I can gloss over the pains of using Unicode in C with every string needing to be an LPS since 0x00 is now a valid code point in UTF-8 (0x for 2 byte Unicode) or suffer the O(n) look up time to do strlen or concatenation operations. Can it get even better? Yep. We also now need to have a Byte order Mark (BOM) to determine the endianness of our characters. Are they little endian or big endian? (or perhaps one of the two possible middle endian encodings?) Who knows? String processing with unicode is unpleasant to say the least. I suppose that's what we get when we things are designed by committee. But Hey! The great thing about standards is that there are so many to choose from. -- Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Jul 19, 7:07 am, Billy Mays no...@nohow.com wrote: On 7/18/2011 7:56 PM, Steven D'Aprano wrote: Billy Mays wrote: On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Goobers... that would be one of those new-fangled slang terms that the young kids today use to mean its opposite, like bad, wicked and sick, correct? I mention it only because some people might mistakenly interpret your words as a childish and feeble insult against the 98% of the world who want or need more than the 127 characters of ASCII, rather than understand you meant it as a sign of the utmost respect for the richness and diversity of human beings and their languages, cultures, maths and sciences. TL;DR version: international character sets are a problem, and Unicode is not the answer to that problem). As long as I have used python (which I admit has only been 3 years) Unicode has never appeared to be implemented correctly. I'm probably repeating old arguments here, but whatever. Unicode is a mess. When someone says ASCII, you know that they can only mean characters 0-127. When someone says Unicode, do the mean real Unicode (and is it 2 byte or 4 byte?) or UTF-32 or UTF-16 or UTF-8? When using the 'u' datatype with the array module, the docs don't even tell you if its 2 bytes wide or 4 bytes. Which is it? I'm sure that all the of these can be figured out, but the problem is now I have to ask every one of these questions whenever I want to use strings. Secondly, Python doesn't do Unicode exception handling correctly. (but I suspect that its a broader problem with languages) A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF, but you already knew that, as well as everyone else who wants to use strings for some reason). When embedding Python in a long running application where user input is received, it is very easy to make mistake which bring down the whole program. If any user string isn't properly try/excepted, a user could craft a malformed string which a UTF-8 decoder would choke on. Using ASCII (or whatever 8 bit encoding) doesn't have these problems since all codepoints are valid. Another (this must have been a good laugh amongst the UniDevs) 'feature' of unicode is the zero width space (UTF-8 code point 0xE2 0x80 0x8B). Any string can masquerade as any other string by placing few of these in a string. Any word filters you might have are now defeated by some cheesy Unicode nonsense character. Can you just just check for these characters and strip them out? Yes. Should you have to? I would say no. Does it get better? Of course! international character sets used for domain name encoding use yet a different scheme (Punycode). Are the following two domain names the same: tést.com , xn--tst-bma.com ? Who knows! I suppose I can gloss over the pains of using Unicode in C with every string needing to be an LPS since 0x00 is now a valid code point in UTF-8 (0x for 2 byte Unicode) or suffer the O(n) look up time to do strlen or concatenation operations. Can it get even better? Yep. We also now need to have a Byte order Mark (BOM) to determine the endianness of our characters. Are they little endian or big endian? (or perhaps one of the two possible middle endian encodings?) Who knows? String processing with unicode is unpleasant to say the least. I suppose that's what we get when we things are designed by committee. But Hey! The great thing about standards is that there are so many to choose from. -- Bill Thanks for writing that Every time I try to understand unicode and remain stuck I come to the conclusion that I must be an imbecile. Seeing others (probably more intelligent than yours truly) gives me some solace! [And I am writing this from India where there are dozens of languages, almost as many scripts and everyone speaks and writes at least a couple of non-european ones] -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 19/07/2011 03:07, Billy Mays wrote: On 7/18/2011 7:56 PM, Steven D'Aprano wrote: Billy Mays wrote: On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Goobers... that would be one of those new-fangled slang terms that the young kids today use to mean its opposite, like bad, wicked and sick, correct? I mention it only because some people might mistakenly interpret your words as a childish and feeble insult against the 98% of the world who want or need more than the 127 characters of ASCII, rather than understand you meant it as a sign of the utmost respect for the richness and diversity of human beings and their languages, cultures, maths and sciences. TL;DR version: international character sets are a problem, and Unicode is not the answer to that problem). As long as I have used python (which I admit has only been 3 years) Unicode has never appeared to be implemented correctly. I'm probably repeating old arguments here, but whatever. Unicode is a mess. When someone says ASCII, you know that they can only mean characters 0-127. When someone says Unicode, do the mean real Unicode (and is it 2 byte or 4 byte?) or UTF-32 or UTF-16 or UTF-8? When using the 'u' datatype with the array module, the docs don't even tell you if its 2 bytes wide or 4 bytes. Which is it? I'm sure that all the of these can be figured out, but the problem is now I have to ask every one of these questions whenever I want to use strings. That's down to whether it's a narrow or wide Python build. There's a PEP suggesting a fix for that (PEP 393). Secondly, Python doesn't do Unicode exception handling correctly. (but I suspect that its a broader problem with languages) A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF, but you already knew that, as well as everyone else who wants to use strings for some reason). Those aren't codepoints, those are invalid bytes for the UTF-8 encoding. When embedding Python in a long running application where user input is received, it is very easy to make mistake which bring down the whole program. If any user string isn't properly try/excepted, a user could craft a malformed string which a UTF-8 decoder would choke on. Using ASCII (or whatever 8 bit encoding) doesn't have these problems since all codepoints are valid. What if you give an application an invalid JPEG, PNG or other image file? Does that mean that image formats are bad too? Another (this must have been a good laugh amongst the UniDevs) 'feature' of unicode is the zero width space (UTF-8 code point 0xE2 0x80 0x8B). Any string can masquerade as any other string by placing few of these in a string. Any word filters you might have are now defeated by some cheesy Unicode nonsense character. Can you just just check for these characters and strip them out? Yes. Should you have to? I would say no. Does it get better? Of course! international character sets used for domain name encoding use yet a different scheme (Punycode). Are the following two domain names the same: tést.com , xn--tst-bma.com ? Who knows! I suppose I can gloss over the pains of using Unicode in C with every string needing to be an LPS since 0x00 is now a valid code point in UTF-8 (0x for 2 byte Unicode) or suffer the O(n) look up time to do strlen or concatenation operations. 0x00 is also a valid ASCII code, but C doesn't let you use it! There's also Modified UTF-8, in which U+ is encoded as 2 bytes, so that zero-byte can be used as a terminator. You can't do that in ASCII! :-) Can it get even better? Yep. We also now need to have a Byte order Mark (BOM) to determine the endianness of our characters. Are they little endian or big endian? (or perhaps one of the two possible middle endian encodings?) Who knows? String processing with unicode is unpleasant to say the least. I suppose that's what we get when we things are designed by committee. Proper UTF-8 doesn't have a BOM. The rule (in Python, at least) is to decode on input and encode on output. You don't have to worry about endianness when processing Unicode strings internally; they're just a series of codepoints. But Hey! The great thing about standards is that there are so many to choose from. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
rusi wrote: Every time I try to understand unicode and remain stuck I come to the conclusion that I must be an imbecile. http://www.joelonsoftware.com/articles/Unicode.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Mon, Jul 18, 2011 at 7:07 PM, Billy Mays no...@nohow.com wrote: On 7/18/2011 7:56 PM, Steven D'Aprano wrote: Billy Mays wrote: On 07/17/2011 03:47 AM, Xah Lee wrote: 2011-07-16 I gave it a shot. It doesn't do any of the Unicode delims, because let's face it, Unicode is for goobers. Goobers... that would be one of those new-fangled slang terms that the young kids today use to mean its opposite, like bad, wicked and sick, correct? I mention it only because some people might mistakenly interpret your words as a childish and feeble insult against the 98% of the world who want or need more than the 127 characters of ASCII, rather than understand you meant it as a sign of the utmost respect for the richness and diversity of human beings and their languages, cultures, maths and sciences. TL;DR version: international character sets are a problem, and Unicode is not the answer to that problem). As long as I have used python (which I admit has only been 3 years) Unicode has never appeared to be implemented correctly. I'm probably repeating old arguments here, but whatever. Unicode is a mess. When someone says ASCII, you know that they can only mean characters 0-127. When someone says Unicode, do the mean real Unicode (and is it 2 byte or 4 byte?) or UTF-32 or UTF-16 or UTF-8? When using the 'u' datatype with the array module, the docs don't even tell you if its 2 bytes wide or 4 bytes. Which is it? I'm sure that all the of these can be figured out, but the problem is now I have to ask every one of these questions whenever I want to use strings. It doesn't matter. When you use the unicode data type in Python, you get to treat it as a sequence of characters, not a sequence of bytes. The fact that it's stored internally as UCS-2 or UCS-4 is irrelevant. Secondly, Python doesn't do Unicode exception handling correctly. (but I suspect that its a broader problem with languages) A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF, but you already knew that, as well as everyone else who wants to use strings for some reason). A Unicode code point is of the form U+. 0xC0 is not a Unicode code point, it is a byte. It happens to be an invalid byte using the UTF-8 byte encoding (which is not Unicode, it's a byte string). The Unicode code point U+00C0 is perfectly valid- it's a LATIN CAPITAL LETTER A WITH GRAVE. When embedding Python in a long running application where user input is received, it is very easy to make mistake which bring down the whole program. If any user string isn't properly try/excepted, a user could craft a malformed string which a UTF-8 decoder would choke on. Using ASCII (or whatever 8 bit encoding) doesn't have these problems since all codepoints are valid. UTF-8 != Unicode. UTF-8 is one of several byte encodings capable of representing every character in the Unicode spec, but it is not Unicode. If you have a Unicode string, it is not a sequence of byes, it is a sequence of characters. If you want a sequence of bytes, use a byte string. If you are attempting to interpret a sequence of bytes as a sequence of text, you're doing it wrong. There's a reason we have both text and binary modes for opening files- yes, there is a difference between them. Another (this must have been a good laugh amongst the UniDevs) 'feature' of unicode is the zero width space (UTF-8 code point 0xE2 0x80 0x8B). Any string can masquerade as any other string by placing few of these in a string. Any word filters you might have are now defeated by some cheesy Unicode nonsense character. Can you just just check for these characters and strip them out? Yes. Should you have to? I would say no. Does it get better? Of course! international character sets used for domain name encoding use yet a different scheme (Punycode). Are the following two domain names the same: tést.com , xn--tst-bma.com ? Who knows! I suppose I can gloss over the pains of using Unicode in C with every string needing to be an LPS since 0x00 is now a valid code point in UTF-8 (0x for 2 byte Unicode) or suffer the O(n) look up time to do strlen or concatenation operations. That is using UTF-8 in C. Which, again, is not the same thing as Unicode. Can it get even better? Yep. We also now need to have a Byte order Mark (BOM) to determine the endianness of our characters. Are they little endian or big endian? (or perhaps one of the two possible middle endian encodings?) Who knows? String processing with unicode is unpleasant to say the least. I suppose that's what we get when we things are designed by committee. And that is UTF-16 and UTF-32. Again, those are byte encodings. They are not Unicode. When you use a library capable of handling Unicode, you never see those- you just have a string with characters in it. But Hey! The great thing about
os.path.isdir do not work for Foder named '2011-07-03'
I want to make sure that folder exists. '2011-07-03' is really exists. but 'os.path.isdir' say false Does anyone know why? os.path.isdir(C:\Users\조창준\Desktop\logs) True os.path.isdir(C:\Users\조창준\Desktop\logs\2011-07-03) False -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Billy Mays wrote: TL;DR version: international character sets are a problem, and Unicode is not the answer to that problem). Shorter version: FUD. Yes, having a rich and varied character set requires work. Yes, the Unicode standard itself, and any interface to it (including Python's) are imperfect (like anything created by fallible humans). But your post is a long and tedious list of FUD with not one bit of useful advice. I'm not going to go through the whole post -- life is too short. But here are two especially egregious example showing that you have some fundamental misapprehensions about what Unicode actually is: Python doesn't do Unicode exception handling correctly. (but I suspect that its a broader problem with languages) A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF, but you already knew that, as well as everyone else who wants to use strings for some reason). and then later: Another (this must have been a good laugh amongst the UniDevs) 'feature' of unicode is the zero width space (UTF-8 code point 0xE2 0x80 0x8B). This is confused. Unicode text has code points, text which has been encoded is nothing but bytes and not code points. UTF-8 code point does not even mean anything. The zero width space has code point U+200B. The bytes you get depend on which encoding you want: zws = u'\N{Zero Width Space}' zws u'\u200b' zws.encode('utf-8') '\xe2\x80\x8b' zws.encode('utf-16') '\xff\xfe\x0b ' But regardless of which bytes it is encoded into, ZWS always has just a single code point: U+200B. You say A good example of this is with UTF-8 where there are invalid code points ( such as 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, ..., 0xFF but I don't even understand why you think this is a problem with Unicode. 0xC0 is not a code point, it is a byte. Not all combinations of bytes are legal in all files. If you have byte 0xC0 in a file, it cannot be an ASCII file: there is no ASCII character represented by byte 0xC0, because hex 0xCO = 192, which is larger than 127. Likewise, if you have a 0xC0 byte in a file, it cannot be UTF-8. It is as simple as that. Trying to treat it as UTF-8 will give an error, just as trying to view a mp3 file as if it were a jpeg will give an error. Why you imagine this is a problem for Unicode is beyond me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.isdir do not work for Foder named '2011-07-03'
2011/7/19 Nulpum changjun@gmail.com: I want to make sure that folder exists. '2011-07-03' is really exists. but 'os.path.isdir' say false Does anyone know why? os.path.isdir(C:\Users\조창준\Desktop\logs) True os.path.isdir(C:\Users\조창준\Desktop\logs\2011-07-03) False Works here. Are you sure that it is not a file ? os.path.isdir('/tmp/2011-07-03') True Python 2.7.1 (r271:86832, Apr 12 2011, 16:15:16) [GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2 Kushal -- http://fedoraproject.org http://kushaldas.in -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.isdir do not work for Foder named '2011-07-03'
What is the output of: os.path.exists(C:\Users\조창준\Desktop\logs\2011-07-03) ? One possible issue here is that for some reason os.path.isdir() can't even access the directory either because of permissions, misinterpretation of the path, or some other reason. Michael 2011/7/19 Nulpum changjun@gmail.com: I want to make sure that folder exists. '2011-07-03' is really exists. but 'os.path.isdir' say false Does anyone know why? os.path.isdir(C:\Users\조창준\Desktop\logs) True os.path.isdir(C:\Users\조창준\Desktop\logs\2011-07-03) False -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.isdir do not work for Foder named '2011-07-03'
Nulpum wrote: I want to make sure that folder exists. '2011-07-03' is really exists. but 'os.path.isdir' say false Does anyone know why? Yes. print logs/2011-07-03 logs/2011-07-03 print logs\2011-07-03 logs�1-07-03 Don't use backslashes as path separators in Python. Backslashes are used for string escapes. \n means newline, not backslash n \t means tab, not backslash t and \201 means octal character 0201 (hex 'x81', decimal 129). There are three solutions: (1) Escape every backslash with an extra backslash: print logs\\2011-07-03 logs\2011-07-03 (2) Use forward slashes, as Windows will happily accept them instead of backslashes. (3) Use another operating system. *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.isdir do not work for Foder named '2011-07-03'
Nulpum wrote in news:0bf400a3-735c-487a-8d74- feb3b56be...@g5g2000prn.googlegroups.com in gmane.comp.python.general: I want to make sure that folder exists. '2011-07-03' is really exists. but 'os.path.isdir' say false Does anyone know why? os.path.isdir(C:\Users\Á¶Ã¢ÁØ\Desktop\logs) True os.path.isdir(C:\Users\Á¶Ã¢ÁØ\Desktop\logs\2011-07-03) False Maybe it isn't a directory, but a file, what does os.path.exists() return. Also could it be a Shortcut in which case 2011-07-03.lnk will exist. Also have you left Hide extensions for known file types switched on, in which case it may really be 2011-07-03.zip for example, a file not a directory even though Windows explorer shows it as a directory. -- Rob. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Jul 19, 8:11 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: rusi wrote: Every time I try to understand unicode and remain stuck I come to the conclusion that I must be an imbecile. http://www.joelonsoftware.com/articles/Unicode.html -- Steven Yes Ive read that and understood a little bit more thanks to it. But for the points raised in this thread this one from Joel is more relevant: http://www.joelonsoftware.com/articles/LeakyAbstractions.html Some evidences of leakiness: code point vs character vs byte encoding and decoding UTF-x and UCS-y Very important and necessary distinctions? Maybe... But I did not need them when my world was built of the 127 bricks of ASCII. My latest brush with unicode was when I tried to port construct to python3. http://construct.wikispaces.com/ If unicode 'just works' you should be able to do it in a jiffy? [And if you did I would be glad to be proved wrong :-) ] -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Tue, Jul 19, 2011 at 2:59 PM, rusi rustompm...@gmail.com wrote: Some evidences of leakiness: code point vs character vs byte encoding and decoding UTF-x and UCS-y Very important and necessary distinctions? Maybe... But I did not need them when my world was built of the 127 bricks of ASCII. Codepoint vs byte is NOT an abstraction. Unicode consists of characters, where each character is represented by a number called its codepoint. Since computers work with bytes, we need a way of encoding those characters into bytes. It's no different from encoding a piece of music in bytes, and having it come out as 0x90 0x64 0x40. Are those bytes an abstraction of the note? No. They're an encoding of a MIDI message that requests that the note be struck. The note itself is an abstraction, if you like; but the bytes to create that note could be delivered in a variety of other ways. A Python Unicode string, whether it's Python 2's 'unicode' or Python 3's 'str', is a sequence of characters. Since those characters are stored in memory, they must be encoded somehow, but that's not our problem. We need only care about encoding when we save those characters to disk, transmit them across the network, or in some other way need to store them as bytes. Otherwise, there is no abstraction, and no leak. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs -vs- Spaces: Tabs should have won.
Andrew Berg bahamutzero8...@gmail.com wrote: I'm not saying it's wise Why not? It just makes it more difficult to follow the pattern when you add new code. If you have an editor mnaging that for you, then you might as well have the editor go all tabs or all spaces to avoid trouble. Vi and friends with ts=8 and sw=4 will use 4 spaces, then tab, then tab plus 4 spaces, then two tabs, etc. That's recognizable, but I still convert such a file to all spaces when I find one. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
Matt Joiner anacro...@gmail.com added the comment: Feel like a total noob: Where do I get the latest source? I can't find any pre-release tarballs for 3.3, and the suggested py3k checkout doesn't work: $ hg clone http://hg.python.org/cpython#py3k py3k abort: unknown revision 'py3k'! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
Ned Deily n...@acm.org added the comment: See the developer's guide: http://docs.python.org/devguide/setup.html#getting-the-source-code hg clone http://hg.python.org/cpython directory_name -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
Matt Joiner anacro...@gmail.com added the comment: This version is fixed for me: $ ./python Python 3.3.0a0 (default:7520f1bf0a81, Jul 18 2011, 17:12:12) [GCC 4.1.2 20070115 (SUSE Linux)] on linux2 -- versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
STINNER Victor victor.stin...@haypocalc.com added the comment: @pitrou: Antoine, do you think that the following commit should be backported from 3.3 to 3.2? New changeset 3c7792ec4547 by Victor Stinner in branch 'default': Issue #12175: BufferedReader.read(-1) now calls raw.readall() if available. http://hg.python.org/cpython/rev/3c7792ec4547 It changes BufferedReader.read() behaviour a *little* bit. Only a little because FileIO.read(-1) calls FileIO.readall() internally for example. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12133] ResourceWarning in urllib.request
STINNER Victor victor.stin...@haypocalc.com added the comment: I reopen the issue. -- resolution: fixed - accepted status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12133 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12133] ResourceWarning in urllib.request
STINNER Victor victor.stin...@haypocalc.com added the comment: (Oh, I missed Antoine's comment, yes, reopen a new issue) -- resolution: accepted - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12133 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12577] Misleading shutil.move docs regarding when os.rename is used
Catalin Iacob iacobcata...@gmail.com added the comment: Senthil's proposal in msg140543 has +1 from me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12577 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12133] ResourceWarning in urllib.request
Ugra Dániel daniel.u...@gmail.com added the comment: Sorry, I've forgotten to post a reference to the new bug: #12576 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12133 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12576] urlib.request fails to open some sites
STINNER Victor victor.stin...@haypocalc.com added the comment: h.close() (HTTPConnection.close) in the finally block of AbstractHTTPHandler.do_open() calls indirectly r.close() (HTTPResponse.close). The problem is that the content of the response cannot be read if its close() method was called. The changelog of the fix (commit ad6bdfd7dd4b) is: Issue #12133: AbstractHTTPHandler.do_open() of urllib.request closes the HTTP connection if its getresponse() method fails with a socket error. Patch written by Ezio Melotti. The HTTP connection is not only closed in case of an error, but it is always closed. It's a bug because we cannot read the content of www.imdb.com, whereas it works without the commit. Test script: --- import urllib.request, gc print(python.org) with urllib.request.urlopen(http://www.python.org/;) as page: content = page.read() print(content: %s... % content[:40]) gc.collect() print(imdb.com) with urllib.request.urlopen(http://www.imdb.com/;) as page: content = page.read() print(content: %s... % content[:40]) gc.collect() print(exit) --- -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12576] urlib.request fails to open some sites
STINNER Victor victor.stin...@haypocalc.com added the comment: ValueError('I/O operation on closed file') error comes from HTTPResponse.__enter__() which is implemented in IOBase: def __enter__(self): # That's a forward reference self._checkClosed() return self -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12576] urlib.request fails to open some sites
Changes by Davide Rizzo sor...@gmail.com: -- nosy: +davide.rizzo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12576] urlib.request fails to open some sites
STINNER Victor victor.stin...@haypocalc.com added the comment: imdb.com and python.org use HTTP/1.1. imdb.com server sends a Transfer-encoding: chunked header whereas python.org doesn't. python.org has a Connection: close header, whereas imdb.com doesn't. The more revelant difference for this issue is the Connection: close header: HTTPResponse.wil_close is True if Connection: close header is present (see _check_close() method), it returns False otherwise. HTTPConnection.getresponse() keeps a reference to the response if will_close is False, or calls its close() method otherwise. The Cneonction: close header looks to be a quirk of Netscaler loadbalancers. It is sometimes nnCoection uses the same load balancer. There are buggy web servers, Python should not raise a I/O closed file error on such server. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
Antoine Pitrou pit...@free.fr added the comment: Antoine, do you think that the following commit should be backported from 3.3 to 3.2? No, I don't think so. -- versions: -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5505] sys.stdin.read() doesn't return after first EOF on Windows
STINNER Victor victor.stin...@haypocalc.com added the comment: No, I don't think so. The issue is already fixed in 3.3, so you agree to not fix it in Python 3.2? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5505 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6476] MSVCRT's spawnve/spawnvpe are not thread safe
Steve Hill python.20.hi...@spamgourmet.com added the comment: Why has this bug been resolved as won't fix? It seems to me that this is a valid issue with something that has not been deprecated, yet it has been decided neither to fix it (despite there being an offer by the originator to submit a patch) nor even to document the deficiency. We've been using SCons for the last 3-4 years, during which time we have been plagued by this issue - more so as multi-core machines have become more prevalent. There was a thread on the SCons Users mailing list in March '09, which stopped short of diagnosing the problem and we've lived with it ever since - putting it down to Python being a bit flaky. I now discover that it is an issue that has been diagnosed two years ago and deliberately left in the implementation of the language. Simply saying you should use subprocess is not helpful; SCons at that time was supporting all Python versions back to 2.0 (possibly earlier) so couldn't rely on the subprocess module being present. Ideally, it should be worked-around so that these functions can safely be used on all platforms without requiring mutual exclusion in the application. However, it seems to me that, at a bare minimum, it should be documented that these functions are not thread safe under Windows. -- nosy: +steve_hill ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6476 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12581] Increased test coverage of test_urlparse
R. David Murray rdmur...@bitdance.com added the comment: I haven't reviewed your tests, but a couple quick comments: we generally prefer duck typing to the use of isintance or ABCs, but sometimes the latter is better (it's a judgement call). I haven't done a deep dive in the code you modified, but from the looks of the code quoted in your patch I'd say that doing 'iter(v)' inside the try/except would be the way to find out if one can loop over the object, which appears to be the only aspect of sequenceness the code cares about. As for coverage, you are right that it is quite possible to get caught up in the statistics. That said, if you *don't* have domain knowledge, giving us a set of tests to look at and evaluate is better than not having such a set of tests. Pointing out any tests that you aren't sure about the validity of is helpful in any case. The overall goal of the test suite is to test the *API* of the library functions. This is so that alternate implementations can use it as a validation test suite (Sometimes we have CPython specific tests, in which case we mark them as such). So testing internal implementation details is not as helpful as testing behavior. If you find you have to use a white box test (one that pokes at the internals as opposed to making an appropriate call to the API), then the code you can't otherwise test becomes suspect and an appropriate subject for another issue (what is this code for? I can't get it to trigger.) Finally, your point about comprehensive tests at least showing up behavior changes is valid. If you write tests that you aren't sure are correct behavior, put in an XXX comment to that effect. If you just have no idea, you can mark a whole block of tests as this improves coverage, I have no idea if the behavior is valid or not, and we'll either sort it out when we review or commit the tests or just leave the comment in. Thanks for working on this. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12581 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12581] Increased test coverage of test_urlparse
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12581 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12167] test_packaging reference leak
Éric Araujo mer...@netwok.org added the comment: I would call .copy() on the original dicts rather than remembering an explicit empty dict. I thought about that and decided to use an empty dict as a way to add a check that the caches should start empty. Maybe it was misguided and I should instead add a unit test for that, or not bother altogether. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12167 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1626300] 'Installing Python Modules' does not work for Windows
Éric Araujo mer...@netwok.org added the comment: On Windows, scripts run with whatever name -- no extension or other extensions. Thanks, this means that the docs can continue to say just “pysetup3”, without “.py”. (I wonder how Windows manages to run the script without file extension!) I have tested this from both IDLE and command line. You can run command-line scripts from IDLE? Can you also comment on my proposed note about adding Scripts to PATH? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1626300 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12582] lib-dynload missing in python install
New submission from Paul Weiss psw...@gmail.com: I am trying to install python 2.7 on my Redhat machine. It installs most of the files, but it doesn't install the lib-dynload directory. I have set every path, done every install and clean I could think of but I can't get it to work. I have tried 2.7, 2.7.1 and 2.7.2 and none of them install. What could cause this? -- components: Build, Installation messages: 140578 nosy: Paul.Weiss priority: normal severity: normal status: open title: lib-dynload missing in python install type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12582 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12582] lib-dynload missing in python install
Éric Araujo mer...@netwok.org added the comment: I’m assuming you’re installing a Python from python.org, not the one from Red Hat. Can you give us the configure and make commands you ran? -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12582 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12479] Add HTTPErrorProcessor class definition
Éric Araujo mer...@netwok.org added the comment: It seems to me that the doc after the patch is barely more helpful. It does not explain when and how one would see or use the class, nor what it does. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12479 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12582] lib-dynload missing in python install
Paul Weiss psw...@gmail.com added the comment: Correct, I am using the source from http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz make clean ./configure --prefix=/opt/Python-2.7 make sudo make install I get this: /usr/bin/install -c -m 644 ./LICENSE /opt/Python-2.7/lib/python2.7/LICENSE.txt PYTHONPATH=/opt/Python-2.7/lib/python2.7 \ ./python -Wi -tt /opt/Python-2.7/lib/python2.7/compileall.py \ -d /opt/Python-2.7/lib/python2.7 -f \ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ /opt/Python-2.7/lib/python2.7 Traceback (most recent call last): File /opt/Python-2.7/lib/python2.7/compileall.py, line 17, in module import struct File /opt/Python-2.7/lib/python2.7/struct.py, line 1, in module from _struct import * ImportError: No module named _struct make: *** [libinstall] Error 1 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12582 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12479] Add HTTPErrorProcessor class definition
Éric Araujo mer...@netwok.org added the comment: Ah, I see that the class is referenced earlier in the file, and that its methods come after. I’d put the class definition just before the methods. (I would even refactor the reST to use nested class/method combo, but that’s a minor markup cleanup, not a content improvement.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12479 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12582] lib-dynload missing in python install
R. David Murray rdmur...@bitdance.com added the comment: Also, are you using a linux3 kernel? -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12582 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12582] lib-dynload missing in python install
Paul Weiss psw...@gmail.com added the comment: No, Redhat's 2.6.9. Could that be the issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12582 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12576] urlib.request fails to open some sites
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com