Re: [Perl Golf] Round 1

2012-02-05 Thread Chris Angelico
On Mon, Feb 6, 2012 at 10:03 AM, Heiko Wundram wrote: > You're only allowed to bash him for one-liners as soon as he formulates > something that in some way or another resembles a programming challenge, and > not some incoherent listing of words without actual intent... ;-) Nah, one-liners are fu

Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Chris Angelico
On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy wrote: > On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: >> >> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor >> wrote: >> >>> A 4 year old compiler? >>> >>> I also have MSVC11 installed. Can the python project add support for >>> that so that we aren't w

Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-06 Thread Chris Angelico
On Mon, Feb 6, 2012 at 6:39 PM, Terry Reedy wrote: > On 2/6/2012 1:53 AM, Chris Angelico wrote: >> I suppose there's no chance of moving to a free compiler? > > VC express is free-as-in-beer. The whole V. Studio is free to core > developers. MS may not *like* open-source

Re: iterating over list with one mising value

2012-02-07 Thread Chris Angelico
On Wed, Feb 8, 2012 at 8:25 AM, Aaron France wrote: > for i in range(0, len(x), 2): >    print x[i-1], x[i] I think you want x[i], x[i+1] here, but in any case, this is a fairly standard non-Python way to do this sort of thing. There's a variety of more Pythonic ways to loop, but every now and th

Re: Id of methods

2012-02-08 Thread Chris Angelico
On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > I am trying to see if I could get more of Python without being insane. Oh, I thought insanity was a prerequisite... anyway. > print Boo.__dict__ > > {'__module__': '__main__', 'ball': , 'daf': > , '__dict__ ..} > > print  hex(id(Boo.daf)) > 0x27

Re: Cycle around a sequence

2012-02-08 Thread Chris Angelico
On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano wrote: > If your data is humongous but only available lazily, buy more memory :) Or if you have a huge iterable and only need a small index into it, snag those first few entries into a list, then yield everything else, then yield the saved ones: de

Re: Cycle around a sequence

2012-02-09 Thread Chris Angelico
On Thu, Feb 9, 2012 at 7:33 PM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> def cycle(seq,n): >>         seq=iter(seq) >>         lst=[next(seq) for i in range(n)] >>         try: >>                 while True: yield

Re: frozendict

2012-02-10 Thread Chris Angelico
On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice wrote: > The only thing needed to avoid the hash collision is that your hash > function is not not 100% predictable just by looking at the python > source code.  I don't see why every dict would have to be created > differently.  I would think having th

Re: Removing items from a list

2012-02-10 Thread Chris Angelico
On Sat, Feb 11, 2012 at 7:04 AM, Thomas Philips wrote: > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in x: >        if i % 2 == 0: >                x.remove(i) Just a quickie, is there a reason you can't use a list comprehension? x = [i for i in x if i % 2] ChrisA -- http://mail.python.org/mailm

Re: Python usage numbers

2012-02-11 Thread Chris Angelico
On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow wrote: > However, in at > least one current thread (on python-ideas) and at a variety of times > in the past, _some_ people have found Unicode in Python 3 to make more > work. If Unicode in Python is causing you more work, isn't it most likely that the

Re: Python usage numbers

2012-02-11 Thread Chris Angelico
On Sun, Feb 12, 2012 at 1:36 PM, Rick Johnson wrote: > On Feb 11, 8:23 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> "I have a file containing text. I can open it in an editor and see it's >> nearly all ASCII text, except for a few weird and bizarre characters like >> £ © ± or ö.

Re: Python usage numbers

2012-02-11 Thread Chris Angelico
On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano wrote: > You can't say that it cost you £10 to courier your résumé to the head > office of Encyclopædia Britanica to apply for the position of Staff > Coördinator. True, but if it cost you $10 (or 10 GBP) to courier your curriculum vitae to the hea

Re: Python usage numbers

2012-02-12 Thread Chris Angelico
On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > The situation before ascii is like where we ended up *before* unicode. > Unicode aims to replace all those byte encoding and character sets with > *one* byte encoding for *one* character set, which will be a great > simplification. It is the id

Re: Python usage numbers

2012-02-12 Thread Chris Angelico
On Mon, Feb 13, 2012 at 11:03 AM, Dave Angel wrote: > On 02/12/2012 06:29 PM, Steven D'Aprano wrote: >> I think you mean 4 times as many bytes as characters. Unless you have 32 >> bit bytes :) >> >> > Until you have 32 bit bytes, you'll continue to have encodings, even if only > a couple of them.

Re: Python usage numbers

2012-02-12 Thread Chris Angelico
On Mon, Feb 13, 2012 at 3:48 PM, Rick Johnson wrote: > The problem with bytes is not encodings or OS's. Can you guess what > the REAL problem is? ..take all the time you need. The REAL problem is trolls. But they're such fun, and so cute when they get ranting... ChrisA -- http://mail.python.or

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Chris Angelico
On Tue, Feb 14, 2012 at 5:38 AM, Ian Kelly wrote: > "... Rights, that > **AMONG** these are Life, Liberty and the pursuit of Happiness." AMONG our rights are such elements as Life, Liberty, the Pursuit of Happiness, and an almost fanatical devotion to the Founding Fathers I'll come in again.

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Chris Angelico
Rick, you are either... On Tue, Feb 14, 2012 at 8:01 AM, Rick Johnson wrote: > I can however tell you that what DOES matter is the continued > improvement of the base gene pool. Yes, this improvement comes at a > cost; the cost of the individual. Those with quality genes will reap > the rewards,

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Chris Angelico
On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson wrote: > # Py>=3.0 > py> sum(earner.get_income(2012) for earner in earners2012) / > len(earners2012) > average_income > > Once you exceed that amount you are robbing your fellow man. How can > you justify making more than your fair share UNLESS someon

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Chris Angelico
On Wed, Feb 15, 2012 at 11:21 AM, Rick Johnson wrote: > On Feb 14, 2:41 am, John O'Hagan wrote: >> This is a failure to acknowledge the is/ought problem, and is usually >> compounded (Rick is no exception) by the equally mistaken view that there >> exist >> "superior" individuals whose possessio

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Chris Angelico
On Wed, Feb 15, 2012 at 11:48 AM, Rick Johnson wrote: > Duncan, your reading and comprehension skills are atrocious. Please re- > read the paragraph you quoted, then spend some time "comprehending" > it, then show me where i stated that "antibiotics cure viral > infections". psst: i NEVER said any

Re: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-15 Thread Chris Angelico
On Thu, Feb 16, 2012 at 5:48 AM, Dave Angel wrote: > When you reply to a known bot, please include some indication of the fact, > so we know your message can be ignored as well. Sometimes I wonder about 8. Is there a real person there, as well as the bot? A lot of his/its posts look too intel

Re: Reading sub-string from a file

2012-02-16 Thread Chris Angelico
On Thu, Feb 16, 2012 at 8:52 PM, Smiley 4321 wrote: > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_

Re: Is this the right list?

2012-02-16 Thread Chris Angelico
On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: > On Feb 15, 4:04 pm, Terry Reedy wrote: >> On 2/15/2012 4:51 PM, Alan McKay wrote: >> >> > Is this the right list? > > This is neither the "right" or "left" list, however, it may be either > the correct or incorrect depending on your question.

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-17 Thread Chris Angelico
On Sat, Feb 18, 2012 at 12:13 PM, Rick Johnson wrote: > Here is a list of taxes most everyone else will encounter: You forgot the Microsoft Tax and the Stupid Tax. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Python LOC, .exe size, and refactoring

2012-02-22 Thread Chris Angelico
On Wed, Feb 22, 2012 at 4:29 PM, Steven D'Aprano wrote: > While I think 60MB for a basic calculator app is taking the piss, this is > 2011 not 1987 and we don't have to support floppy disks any more. 11MB > for a GUI app is nothing to be worried about. That takes, what, 3 minutes > to download eve

Re: storing in list and retrieving.

2012-02-22 Thread Chris Angelico
write one program that writes that format and another that reads it. The open() built-in function will open files for reading or writing, so that's a good place to start. Get as far as you can on your own, and if you get stuck, ask the list for more specific help. Good luck! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: storing in list and retrieving.

2012-02-23 Thread Chris Angelico
On Thu, Feb 23, 2012 at 7:45 PM, Smiley 4321 wrote: > It requires concepts of 'python persistence' for the code to be designed . > > Else it simple. > > Looking for some flow?? Go through the tutorial on python.org if you haven't, get some code written, and then codify your questions :) Chances a

Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: > _sentinel = object() > > def sum(iterable, start=_sentinel): >    if start is _sentinel: > > del _sentinel Somewhat off-topic: Doesn't the if statement there do a lookup for a global, which would mean that 'del _sentinel' will cause it to

Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
27;del' is treated like a unique non-providable object, only possible in an argument list and only if the argument was omitted. No more proliferation of individual sentinels... what do you think? (I picked "del" because it's an existing keyword. Fairly arbitrary ch

Optional arguments syntax (was Re: sum() requires number, not simply __add__)

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 9:09 AM, Arnaud Delobelle wrote: > On 23 February 2012 22:04, Chris Angelico wrote: >> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: >>> def sum(iterable, start=_sentinel, _sentinel=_sentinel): >> >> Is this a reason for Python t

Re: sum() requires number, not simply __add__

2012-02-23 Thread Chris Angelico
On Fri, Feb 24, 2012 at 10:33 AM, Steven D'Aprano wrote: > Yes, deleting _sentinel will cause the custom sum to fail, and yes, you > have missed something. > > If the caller wants to mess with your library and break it, they have > many, many ways to do so apart from deleting your private variable

Re: Please verify!!

2012-02-24 Thread Chris Angelico
On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano wrote: > Personally, I prefer tabs for theoretical reasons and spaces for > practical ones. I think that the world would be better off if we all > standardised on tabs instead of spaces, but since that's not going to > happen, I can interoperate be

Re: How to handle calling functions from cli

2012-02-24 Thread Chris Angelico
On Sat, Feb 25, 2012 at 9:16 AM, Rodrick Brown wrote: > m = { 'a': 'checkDisks()', >          'b': 'checkMemSize()', >          'c': 'checkBondInterfaces()' >    } > >    runlist = [ c for c in m.keys() if c not in r.d ] >    for runable in runlist: >        eval(m[runable]) It's a reasonable tec

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Chris Angelico
On Sat, Feb 25, 2012 at 10:16 AM, Michael Torrie wrote: > Sure but that doesn't answer the question posed.  How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily.  But baring that, > how does Rick suggest

Re: Please verify!!

2012-02-24 Thread Chris Angelico
On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: > Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. PEP 8 applies only to Python code, our standard is across all our languages :) But yes, I'm a horrible sinner and I like tabs. They separate the display (do you want tabs to

Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3

2012-02-26 Thread Chris Angelico
On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: > Benjamin Peterson writes: > >> We're pleased to announce the immediate availability of release candidates >> for >> Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . > > If you're pleased to announce their immediate availability, then please > do that!

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Chris Angelico
On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners wrote: > That means: > if maxlength and (len(string) <= maxlength): > > is equivalent to > if (maxlength is not None) and (len(string) <= maxlength): On the contrary, it means they are distinctly NOT equivalent. The shorter form would treat a max

Re: pickle handling multiple objects ..

2012-02-26 Thread Chris Angelico
On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__pete...@web.de> wrote: > This is however a bit errorprone. If you accidentally write the loading code > as > > fruit, beverages, vegetables = pickle.load(f) > > you'll end up drinking potatoes. You mean vodka? :) Additionally, you'll get a weird cr

Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3

2012-02-26 Thread Chris Angelico
On Sun, Feb 26, 2012 at 11:21 PM, Ben Finney wrote: > Unless “release candidate” means nothing like what those words imply, it > can't be both a release candidate *and* released. > > Either it's released, or it's not. If it's a release candidate, it's not > released yet. If it's released, it's no

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-26 Thread Chris Angelico
On Mon, Feb 27, 2012 at 7:35 AM, Rick Johnson wrote: >  1. you could fight each bully on a case by case bases. >  2. you could empower people to fight bullies as a united group. > > Adopt a public policy that bullying will NOT be > allowed and the perp WILL be punished, and bulling disappears > fo

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Chris Angelico
On Mon, Feb 27, 2012 at 2:51 PM, Steven D'Aprano wrote: > I can see some value for this as a convenience, but not enough to make it > a built-in language feature. Every developer should have at least one > utility module with all the trivial code snippets they frequently use. +1. I used to call m

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-28 Thread Chris Angelico
On Wed, Feb 29, 2012 at 9:56 AM, Rick Johnson wrote: > On Feb 24, 8:54 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > >> In Python 4000, I think for loops should be spelled: >> >> for name in iterable: >>     # for block >> then: >>     # only if not exited with break >> else: >>  

Re: this afternoon's duck typing exercise ...

2012-03-01 Thread Chris Angelico
On Fri, Mar 2, 2012 at 4:15 PM, Cameron Simpson wrote: > Sorry, little technical content here, just a newly hatched programmer: > >  duck typing, an intro >  http://www.flickr.com/photos/cskk/6799351990/in/photostream/ > >  duck typing, resting after the demo >  http://www.flickr.com/photos/cskk/6

Re: lang comparison: in-place algorithm for reversing a list in Perl,Python, Lisp

2012-03-01 Thread Chris Angelico
On Fri, Mar 2, 2012 at 9:04 AM, Xah Lee wrote: > One easy > way to measure it is whether a programer can read and understand a > program without having to delve into its idiosyncrasies. Neither the behavior of ints nor the behavior of IEEE floating point is a "quirk" or an "idiosyncracy". These a

Re: What's the best way to write this regular expression?

2012-03-07 Thread Chris Angelico
On Thu, Mar 8, 2012 at 7:39 AM, John Salerno wrote: > it only > seemed to support Python 2.7. I'm using 3.2. Is 2.7 just the minimum > version it requires? It didn't say something like "2.7+", so I wasn't > sure, and I don't want to start installing a bunch of stuff that will > clog up my director

Re: How to know that two pyc files contain the same code

2012-03-10 Thread Chris Angelico
On Sun, Mar 11, 2012 at 9:52 AM, Steven D'Aprano wrote: > On Sat, 10 Mar 2012 15:48:48 +0100, Gelonida N wrote: > Define "identical" and "the same". > > If I compile these two files: > > > # file ham.py > x = 23 > def func(): >    a = 23 >    return a + 19 > > > > # file = spam.py > def func(): >

Re: Raise X or Raise X()?

2012-03-12 Thread Chris Angelico
On Tue, Mar 13, 2012 at 12:06 AM, James Elford wrote: > I wonder whether you need to use an exception here rather than a yield > statement? Or a return statement, if you're not needing multiple responses. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: How to break long method name into more than one line?

2012-03-12 Thread Chris Angelico
On Tue, Mar 13, 2012 at 3:24 AM, Dennis Lee Bieber wrote: > On 12 Mar 2012 00:30:08 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: >> I expect that naming rule was invented by either people who have heard of >> test driven development, but never actually done it, o

Re: How to break long method name into more than one line?

2012-03-13 Thread Chris Angelico
On Tue, Mar 13, 2012 at 9:30 PM, Jean-Michel Pichavant wrote: > Chris Angelico wrote: >> >> Just never treat them as laws of physics (in >> Soviet Physics, rules break you!). > > hum ... > I wonder how this political message is relevant to the OP problem. Ehh, it&#

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 1:43 AM, xliiv wrote: > Like the topic.. . > I use Python a lot, both Windows and Linux, and it's little weird to have > many python process without fast distinction which is what. I've no idea if it's even possible on Windows. On Linux, what you want is the prctl functio

Re: Style question (Poll)

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 7:37 AM, Croepha wrote: > Which is preferred: > > for value in list: >  if not value is another_value: >    value.do_something() >    break > > --or-- > > if list and not list[0] is another_value: >  list[0].do_something() > > Comments are welcome, Thanks General principle

Re: Python is readable

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 10:54 AM, Arnaud Delobelle wrote: > I don't know this book and there may be a pedagogical reason for the > implementation you quote, but pairwise_sum is probably better > implemented in Python 3.X as: > > def pairwise_sum(list1, list2): >    return [x1 + x2 for x1, x2 in zi

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Thu, Mar 15, 2012 at 9:44 PM, Kiuhnm wrote: > Let's try that. > Show me an example of "list comprehensions" and "with" (whatever they are). I'll do a list comp, because they lend themselves well to one-liners. what_am_i = '\n'.join(["%X\t%c"%(i,i) for i in range(128)]) Okay, that one also use

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Thu, Mar 15, 2012 at 10:27 PM, Kiuhnm wrote: > On 3/15/2012 11:50, Chris Angelico wrote: >> I'll do a list comp, because they lend themselves well to one-liners. >> what_am_i = '\n'.join(["%X\t%c"%(i,i) for i in range(128)]) > > > A few conjec

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Thu, Mar 15, 2012 at 10:59 PM, Kiuhnm wrote: > On 3/15/2012 12:47, Chris Angelico wrote: >> It's a little odd, perhaps, if seen in a vacuum. But everything counts >> from zero - list indices, etc - so it makes sense for range(len(lst)) >> to return indices valid for

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Thu, Mar 15, 2012 at 11:31 PM, Ben Finney wrote: > Another good reason to advocate for proper typography. "John 14:5-7" > indicates a range (because it uses U+2013 EN DASH), whereas "7-5" > indicates subtraction (because it uses U+2212 MINUS SIGN). A hyphen ('-' > U+002D) is inappropriate in ei

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 12:16 AM, Ben Finney wrote: > Chris Angelico writes: > >> On Thu, Mar 15, 2012 at 11:31 PM, Ben Finney >> wrote: >> > Another good reason to advocate for proper typography. "John 14:5-7" >> > indicates a range

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 1:16 AM, Kiuhnm wrote: > Don't worry. Soon you'll be using C++0x :))) I use gcc/g++ with most of the new features enabled. There's some pretty handy features in it. Frankly, though, if I'd known about Cython when I started the current project, I would have argued to write

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 1:30 AM, Kiuhnm wrote: > Sorry, but I can't see how it would make it harder for humans to understand. > Are there particular situations you're referring to? In a trivial example, it's mostly just noise: if a == b# who needs the colon? print(c) But when your condi

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 1:55 AM, Kiuhnm wrote: > By the way, the more elaborate parsing consists of looking for an > END_OF_LINE followed by one or more spaces. It doesn't sound that > complicated. Only in the trivial case. What if you want to break your condition over multiple lines? (Although y

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 2:05 AM, Kiuhnm wrote: > I had thought about the single-line case. What I hadn't thought about is > that Python strives to be as regular as possible, so having different cases > just for saving one keystroke isn't worth it. Yep. Have you read the Zen of Python? >>> import

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 2:14 AM, Roy Smith wrote: > While it's nice to know that we've got the ability to write extensions > in C, not once have we ever felt the need.  I suppose if you're running > a CPU-bound application, that might not be the case, but surprisingly > few applications really are

Re: Python is readable

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 10:52 AM, Steven D'Aprano wrote: > On Fri, 16 Mar 2012 01:48:09 +1100, Chris Angelico wrote: > >> In a trivial example, it's mostly just noise: >> >> if a == b    # who needs the colon? >>     print(c) > > The reader, for t

Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread Chris Angelico
On Fri, Mar 16, 2012 at 5:39 AM, Grant Edwards wrote: > Seems like an awfully obtuse way of doing things -- I don't really > want to have 15 different copies of Python (or even links), and it > requires root privleges every time you want to run a Python program > with the "correct" name. Why do y

Re: Python simulate browser activity

2012-03-16 Thread Chris Angelico
On Fri, Mar 16, 2012 at 1:23 PM, choi2k wrote: > The application aims to simulate user activity including visit a > website and perform some interactive actions (click on the menu, > submit a form, redirect to another pages...etc) > I have found some libraries / plugins which aims to simulate brow

Re: Python is readable

2012-03-16 Thread Chris Angelico
On Sat, Mar 17, 2012 at 7:30 AM, Ethan Furman wrote: > Neil Cerutti wrote: >> >> I am not pedantic. You are wrong. >> > > When saying somebody is wrong, you really should back it up with references > (wiki, dictionary, etc.). I interpret this simply as a witty statement, one that can be thrown in

Re: urllib.urlretrieve never returns???

2012-03-17 Thread Chris Angelico
2012/3/18 Laszlo Nagy : > In the later case, "log.txt" only contains "#1" and nothing else. If I look > at pythonw.exe from task manager, then its shows +1 thread every time I > click the button, and "#1" is appended to the file. try: fpath = urllib.urlretrieve(imgurl)[0]

Re: urllib.urlretrieve never returns???

2012-03-17 Thread Chris Angelico
On Sun, Mar 18, 2012 at 4:31 AM, Laszlo Nagy wrote: > You are right, I should have added "import traceback". However, I tried > this: > >        except: >            self.Log("Exception") > > and still nothing was logged. Another proof is that the number of threads is > increased every time I pres

Re: Python is readable

2012-03-17 Thread Chris Angelico
On Sun, Mar 18, 2012 at 6:59 AM, Kiuhnm wrote: > Could you please explain to me in which way >    mov eax, 3 > should be less readable than >    for i in x: print(i) > ? They are equally readable. The first one sets EAX to 3; the second displays all elements of x on the console. Assembly is reada

Re: Python is readable

2012-03-17 Thread Chris Angelico
On Sun, Mar 18, 2012 at 11:57 AM, Steven D'Aprano wrote: > The vast majority of English speakers write things like: > >    TO DO: And the vast majority of programmers leave out the space, even in non-code. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-17 Thread Chris Angelico
On Sun, Mar 18, 2012 at 1:05 PM, Steven D'Aprano wrote: > I'm not sure if you're making a point there, or just a witty observation, > but for the record I would accept dictionaries adding "todo" as a jargon > entry. I don't think it is widespread enough to count as a regular word, > but if we can

Re: Python is readable

2012-03-18 Thread Chris Angelico
On Mon, Mar 19, 2012 at 8:30 AM, John Ladasky wrote: > What I would say is that, when PROGRAMMERS look at Python code for the > first time, they will understand what it does more readily than they > would understand other unfamiliar programming languages.  That has > value. This is something that

Re: Python is readable

2012-03-18 Thread Chris Angelico
On Mon, Mar 19, 2012 at 12:23 PM, Steven D'Aprano wrote: > On Mon, 19 Mar 2012 09:02:06 +1100, Chris Angelico wrote: > >> On Mon, Mar 19, 2012 at 8:30 AM, John Ladasky >> wrote: >>> What I would say is that, when PROGRAMMERS look at Python code for the >>&

Re: Python is readable

2012-03-20 Thread Chris Angelico
On Wed, Mar 21, 2012 at 1:44 PM, Steve Howell wrote: > I think it's a matter of perspective, so there's no right answer, but > I always think of the program object as also being the grammatical > object, with the implied subject/actor being Python itself.  For > example, consider this code: > >  s

Re: Python is readable

2012-03-20 Thread Chris Angelico
On Wed, Mar 21, 2012 at 3:58 PM, Steve Howell wrote: > So saying "push(stack, item)" or "push(item, stack)" seems very > unsophisticated, almost assembly-like in syntax, albeit at a higher > level conceptually than assembly. Perhaps it does, but "push(stack, item)" and "stack.push(item)" are so c

Re: Python is readable

2012-03-21 Thread Chris Angelico
On Wed, Mar 21, 2012 at 5:52 PM, Steve Howell wrote: > On the one hand, you say that "push(stack, item)" reads quite > differently from "stack.push(item)". > > On the other hand, you say they are "so close to identical as makes no > odds." > > I'm trying to make sense of that.  Are you saying that

Re: Python is readable

2012-03-21 Thread Chris Angelico
On Wed, Mar 21, 2012 at 6:57 PM, Steve Howell wrote: >  verb first: English-imperative ("boil water", "add noodles/salt", > "serve in dish") or math-functional, e.g. sum(a,b,c) >  verb middle: infix, arithmetic-like ("5 plus 4", "10 divided by 2") > or English-descriptive ("Dog bites man") In Eng

Re: Python classes: Simplify?

2012-03-22 Thread Chris Angelico
On Thu, Mar 22, 2012 at 9:51 PM, Steven Lehar wrote: > It seems to me that the Python class system is needlessly confusing. Am I > missing something? > > For example in the class Complex given in the documentation > > class Complex: >     def __init__(self, realpart, imagpart): >         self.r =

Re: Python is readable

2012-03-22 Thread Chris Angelico
On Thu, Mar 22, 2012 at 11:47 PM, Nathan Rice wrote: > Having one core language with > many DSLs that can interoperate is infinitely better than having many > languages that cannot.  A language designed in such a way would also > prevent issues like the Python 2 -> 3 fiasco, because two versions o

Re: Python is readable

2012-03-22 Thread Chris Angelico
On Fri, Mar 23, 2012 at 5:26 AM, Nathan Rice wrote: [regarding Python 2 -> 3] > The extremely slow uptake?  I don't really care one way or another but > a lot of the devs have lamented the issue. By your plan, the slow uptake would be accepted, even encouraged. In fact, your plan is effectively e

Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-22 Thread Chris Angelico
On Fri, Mar 23, 2012 at 4:44 AM, Steven D'Aprano wrote: > The typical developer knows three, maybe four languages > moderately well, if you include SQL and regexes as languages, and might > have a nodding acquaintance with one or two more. I'm not entirely sure what you mean by "moderately well",

Re: Python is readable

2012-03-22 Thread Chris Angelico
On Fri, Mar 23, 2012 at 1:29 AM, Nathan Rice wrote: > For example, your ability to reason about the behavior of the system > you posited as a whole is limited.  Are there parts of the different > modules that can execute concurrently?  Is the output of module1 > guaranteed to be acceptable as the

Re: Python is readable

2012-03-22 Thread Chris Angelico
On Fri, Mar 23, 2012 at 6:33 AM, Nathan Rice wrote: > Pipes do not provide any fine grained control over the concurrent > behavior.  If you want to change the order of calls, suddenly you have > to write a bash script (with its own set of issues), etc. Go back to my original post. I posited a mea

Re: Python is readable

2012-03-22 Thread Chris Angelico
On Fri, Mar 23, 2012 at 6:33 AM, Nathan Rice wrote: > Pipes do not provide any fine grained control over the concurrent > behavior.  If you want to change the order of calls... And to clarify: The "order of calls" in what I described is merely the order of initialization. It's like the order of y

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Chris Angelico
On Fri, Mar 23, 2012 at 1:48 PM, Steve Howell wrote: > On Mar 22, 6:11 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> In any case, I'm not talking about the best developers. I'm talking about >> the typical developer, who by definition is just average. They probably >> know reason

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Chris Angelico
On Fri, Mar 23, 2012 at 7:04 PM, Steve Howell wrote: > If you're that adept at learning languages, then I recommend learning > Ruby just for kicks, but you're not missing *that* much, trust me. > I'd skip past Ruby and learn CoffeeScript. Sure. When I have some spare time... lessee, I think I hav

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-24 Thread Chris Angelico
On Sun, Mar 25, 2012 at 9:08 AM, Tim Delaney wrote: > Being able to pick up a new language (skill, technology, methodology, etc) > is IMO the most important skill for a developer to have. Pick it up quickly, > become proficient with it, leave it alone for a couple of years, pick up the > new versi

Re: verbs in comments [OT]

2012-03-24 Thread Chris Angelico
On Sun, Mar 25, 2012 at 7:32 AM, Colton Myers wrote: > > // Print the number of words... > // Prints the number of words... > > I've seen it both ways, and I don't think anyone will fault you for either. >  I usually use the first version, "commanding" the code to do what I want. >  It's also a ha

Re: [Python-Dev] Playing with a new theme for the docs

2012-03-24 Thread Chris Angelico
On Sun, Mar 25, 2012 at 11:41 AM, Ben Finney wrote: > So, again, why make your browser window *for reading text* that large? > > You have control over how large your window size is, and if you have > purposes so different that they demand different widths, then you can > easily make different-widt

Re: Documentation, assignment in expression.

2012-03-25 Thread Chris Angelico
On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase wrote: > Granted, this can be turned into an iterator with a yield, making the issue > somewhat moot: No, just moving the issue to the iterator. Your iterator has exactly the same structure in it. Personally, I quite like assignment-in-conditional nota

Re: Documentation, assignment in expression.

2012-03-25 Thread Chris Angelico
On Mon, Mar 26, 2012 at 12:48 AM, Tim Chase wrote: > Yeah, it has the same structure internally, but I'm somewhat surprised that > the DB connection object doesn't have an __iter__() that does something like > this automatically under the covers. Sure. That's definitely the truly Pythonic techniq

Re: random number

2012-03-25 Thread Chris Angelico
base 36 conversion on a random integer. Hope that helps! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Chris Angelico
On Mon, Mar 26, 2012 at 10:45 PM, wrote: > I know the print statement produces the same result when both of these two > instructions are executed ,I just want to know Is there any difference > between print 3 and print '3' in Python ? One of them takes the integer 3, converts it into a string,

Re: best way to create warning for obsolete functions and call new one

2012-03-26 Thread Chris Angelico
On Tue, Mar 27, 2012 at 7:26 AM, Gelonida N wrote: > One option I though of would be: > > def obsolete_func(func): >    def call_old(*args, **kwargs): >        print "func is old psl use new one" >        return func(*args, **kwargs) >    return call_old > > and > > def get_time(a='high'): >   ret

Re: Slow termination of process

2012-03-27 Thread Chris Angelico
library/socket.html?highlight=so_reuseaddr I've not actually used the TCPServer class myself, but a cursory glance at the docs suggests that it's possible if you subclass it: http://docs.python.org/library/socketserver.html#SocketServer.BaseServer.allow_reuse_address Chris Angelico -- http://

Re: Slow termination of process

2012-03-27 Thread Chris Angelico
ason not to make these sorts of things into keyword-only arguments? Or, more generally, is there a reason for them to be class variables rather than instance? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Chris Angelico
On Wed, Mar 28, 2012 at 7:56 PM, Peter Daum wrote: > Hi, > > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") What is a string? It's not a series of bytes. You can't convert it without encoding those

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Chris Angelico
On Thu, Mar 29, 2012 at 2:36 AM, Ross Ridge wrote: > Chris Angelico   wrote: >>What is a string? It's not a series of bytes. > > Of course it is.  Conceptually you're not supposed to think of it that > way, but a string is stored in memory as a series of bytes. Note t

Re: RE: Advise of programming one of my first programs

2012-03-28 Thread Chris Angelico
Thu, Mar 29, 2012 at 9:36 AM, Anatoli Hristov wrote: >> > > Um, at least by my understanding, the use of Pickle is also dangerous >> > > if you are not completely sure what is being passed in: >> > >> > Oh goodness yes. pickle is exactly as unsafe as eval is. Try running >> > this code: >> > >> >

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-28 Thread Chris Angelico
On Thu, Mar 29, 2012 at 11:59 AM, Rodrick Brown wrote: > The best skill any developer can have is the ability to pickup languages very > quickly and know what tools work well for which task. Definitely. Not just languages but all tools. The larger your toolkit and the better you know it, the mor

<    13   14   15   16   17   18   19   20   21   22   >