Thanks Steven. Maybe you mean Gnu/Linux when you say Linux.
2011/12/6 <python-list-requ...@python.org>: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-requ...@python.org > > You can reach the person managing the list at > python-list-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > Today's Topics: > > 1. Re: Python-list Digest, Vol 99, Issue 27 (Sergi Pasoev) > 2. Re: Single key press (alex23) > 3. Re: Single key press (Steven D'Aprano) > 4. Re: struct calcsize discrepency? (Nobody) > 5. Re: Questions about LISP and Python. (Alex Mizrahi) > 6. Re: Backspace does not erase in stdout (Nobody) > 7. Re: Single key press (Hans Mulder) > 8. Re: Single key press (Nobody) > 9. Re: Scope of variable inside list comprehensions? (88888 Dihedral) > 10. Re: Scope of variable inside list comprehensions? > (Jean-Michel Pichavant) > > > ---------- Message transféré ---------- > From: Sergi Pasoev <s.pas...@gmail.com> > To: python-list@python.org > Date: Tue, 6 Dec 2011 12:59:54 +0430 > Subject: Re: Python-list Digest, Vol 99, Issue 27 > I do not want GUI, I just want a console application which will read a > single character > input. When you read from stdin for example, you have it to be terminated. > > 2011/12/6 <python-list-requ...@python.org>: >> Send Python-list mailing list submissions to >> python-list@python.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> http://mail.python.org/mailman/listinfo/python-list >> or, via email, send a message with subject or body 'help' to >> python-list-requ...@python.org >> >> You can reach the person managing the list at >> python-list-ow...@python.org >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Python-list digest..." >> >> Today's Topics: >> >> 1. Re: Questions about LISP and Python. (Xah Lee) >> 2. Re: Questions about LISP and Python. (Chris Angelico) >> 3. Re: 70% [* SPAM *] Re: Re: multiprocessing.Queue blocks when >> sending large object (Dennis Lee Bieber) >> 4. Single key press (Sergi Pasoev) >> 5. Re: Fwd: class print method... (Suresh Sharma) >> 6. Re: Single key press (88888 Dihedral) >> 7. Re: Single key press (88888 Dihedral) >> 8. Re: Scope of variable inside list comprehensions? (Rainer Grimm) >> 9. Re: Questions about LISP and Python. (alex23) >> 10. Re: Questions about LISP and Python. (Matt Joiner) >> >> >> ---------- Message transféré ---------- >> From: Xah Lee <xah...@gmail.com> >> To: python-list@python.org >> Date: Mon, 5 Dec 2011 20:36:45 -0800 (PST) >> Subject: Re: Questions about LISP and Python. >> On Dec 5, 4:31 am, Tim Bradshaw <t...@tfeb.org> wrote: >>> On 2011-12-05 11:51:11 +0000, Xah Lee said: >>> >>> > python has more readible syntax, more modern computer language >>> > concepts, and more robust libraries. These qualities in turn made it >>> > popular. >>> >>> Yet you still post here: why? >> >> i don't like python, and i prefer emacs lisp. The primary reason is >> that python is not functional, especially with python 3. The python >> community is full of fanatics with their drivels. In that respect, >> it's not unlike Common Lisp community and Scheme lisp community. >> >> see also: >> >> 〈Python Documentation Problems〉 >> http://xahlee.org/perl-python/python_doc_index.html >> >> 〈Computer Language Design: What's List Comprehension and Why is It >> Harmful?〉 >> http://xahlee.org/comp/list_comprehension.html >> >> 〈Lambda in Python 3000〉 >> http://xahlee.org/perl-python/python_3000.html >> >> 〈What Languages to Hate〉 >> http://xahlee.org/UnixResource_dir/writ/language_to_hate.html >> >> 〈Xah on Programing Languages〉 >> http://xahlee.org/Periodic_dosage_dir/comp_lang.html >> >> Xah >> >> >> >> ---------- Message transféré ---------- >> From: Chris Angelico <ros...@gmail.com> >> To: python-list@python.org >> Date: Tue, 6 Dec 2011 16:10:27 +1100 >> Subject: Re: Questions about LISP and Python. >> On Tue, Dec 6, 2011 at 3:36 PM, Xah Lee <xah...@gmail.com> wrote: >>> i don't like python, and i prefer emacs lisp. The primary reason is >>> that python is not functional, especially with python 3. The python >>> community is full of fanatics with their drivels. In that respect, >>> it's not unlike Common Lisp community and Scheme lisp community. >> >> So you hate Python. Fine. Why post here? Why not just abandon Python >> as a dead loss and go code in Lithp? >> >> Clearly something is keeping you here. Is it that there's something >> about Python that you really like, or are you just trolling? >> >> ChrisA >> >> >> >> ---------- Message transféré ---------- >> From: Dennis Lee Bieber <wlfr...@ix.netcom.com> >> To: python-list@python.org >> Date: Mon, 05 Dec 2011 21:15:09 -0800 >> Subject: Re: 70% [* SPAM *] Re: Re: multiprocessing.Queue blocks when >> sending large object >> On Mon, 5 Dec 2011 18:49:44 +0100, DPalao <dpalao.pyt...@gmail.com> >> wrote: >> >>>Obviously it was not me who added the disgusting "70% [* SPAM *]" string to >>>the subject. And I'd like to know the answer too. >>> >> Based upon your headers, somewhere your message went through a spam >> check program... >> >> X-Greylist: Sender succeeded SMTP AUTH, not delayed by >> milter-greylist-4.3.7 >> (monster.roma2.infn.it [141.108.255.100]); >> Mon, 05 Dec 2011 09:02:22 +0100 (CET) >> X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, >> Antispam-Data: 2011.12.5.74814 >> X-PMX-Spam: 70% >> X-PMX-Spam-report: The following antispam rules were triggered by this >> message: >> Rule Score Description >> RDNS_SUSP_FORGED_FROM 3.500 From domain appears to be forged, >> and arrived via a host with a known suspicious rDNS. >> SXL_IP_DYNAMIC 3.000 Received via a known dynamic IP (SXL lookup): >> 34.140.47.93.fur >> FORGED_FROM_GMAIL 0.100 Appears to forge gmail in the from >> FROM_NAME_ONE_WORD 0.050 Name in From header is a single word >> BODYTEXTP_SIZE_3000_LESS 0.000 Body size of the text/plain part is >> less >> than 3k >> BODY_SIZE_1500_1599 0.000 Message body size is 1500 to 1599 bytes >> BODY_SIZE_2000_LESS 0.000 Message body size is less than 2000 bytes. >> BODY_SIZE_5000_LESS 0.000 Message body size is less than 5000 bytes. >> BODY_SIZE_7000_LESS 0.000 Message body size is less than 5000 bytes. >> RDNS_GENERIC_POOLED 0.000 Sender's PTR record matches generic pooled >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ >> >> >> >> >> ---------- Message transféré ---------- >> From: Sergi Pasoev <s.pas...@gmail.com> >> To: python-list@python.org >> Date: Tue, 6 Dec 2011 10:19:55 +0430 >> Subject: Single key press >> Hi. >> >> I wonder if it is realistic to get a single key press in Python >> without ncurses or >> any similar library. In single key press I mean something like j and k >> in Gnu less >> program, you press the key and and it is captured by the script without need >> to >> press enter afterwards >> >> >> >> ---------- Message transféré ---------- >> From: Suresh Sharma <ss27051...@gmail.com> >> To: Lie Ryan <lie.1...@gmail.com> >> Date: Tue, 6 Dec 2011 11:23:16 +0530 >> Subject: Re: Fwd: class print method... >> Dave / Ryan >> Thanks i have got it and it worked after using repr statement. Thanks >> everyone for their valuable feedback. >> >> >> >> On Mon, Dec 5, 2011 at 6:11 PM, Lie Ryan <lie.1...@gmail.com> wrote: >>> >>> On 12/05/2011 10:18 PM, Suresh Sharma wrote: >>>> >>>> >>>> Pls help its really frustrating >>>> ---------- Forwarded message ---------- >>>> From: Suresh Sharma >>>> Date: Monday, December 5, 2011 >>>> Subject: class print method... >>>> To: "d...@davea.name <mailto:d...@davea.name>" <d...@davea.name >>>> <mailto:d...@davea.name>> >>>> >>>> >>>> Dave, >>>> Thanx for the quick response, i am sorry that i did not explain >>>> correctly look at the code below inspite of this i am just getting class >>>> object at memory location.I am sort i typed all this code on my android >>>> in a hurry so.indentation could.not.be.managed but this.similar code >>>> when i run all my objects created by class deck are not shown but stored >>>> in varioia meory locations. How can i display them. >>>> >>> >>> I think you're in the right track, however I suspect you're running the >>> code in the shell instead of as a script. The shell uses __repr__() to >>> print objects instead of __str__(), so you either need to use 'print' or >>> you need to call str(), note the following: >>> >>> Python 2.7.2+ (default, Oct 4 2011, 20:06:09) >>> [GCC 4.6.1] on linux2 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> suits = ['spades', 'clubs', 'diamonds', 'hearts'] >>> >>> ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', >>> >>> 'K'] >>> >>> class Card: >>> ... def __init__(self, rank, suit): >>> ... self.suit = suit >>> ... self.rank = rank >>> ... def __str__(self): >>> ... return suits[self.suit] + ' ' + ranks[self.rank] >>> ... >>> >>> Card(2, 3) #1 >>> <__main__.Card instance at 0x7f719c3a20e0> >>> >>> str(Card(2, 3)) #2 of your >>> 'hearts 3' >>> >>> print Card(2, 3) #3 >>> hearts 3 >>> >>> In #1, the output is the __repr__() of your Card class; you can modify this >>> output by overriding the __repr__() on your Card class. >>> >>> In #2, the output is the __repr__() of a string, the string is the return >>> value from __str__() of your Card class. The repr of a string is the string >>> enclosed in quotes, which is why there is an extra pair of quotes. >>> >>> In #3, you're 'print'-ing a string, the string is the return value from >>> __str__() of your Card class. There's no extra quotes, since 'print' prints >>> the string itself, not the repr of the string. >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> >> >> >> -- >> Suresh Sharma >> Regional Project Manager, >> O2F,Mumbai >> Maharashtra-400101. >> >> >> >> >> >> ---------- Message transféré ---------- >> From: 88888 Dihedral <dihedral88...@googlemail.com> >> To: comp.lang.pyt...@googlegroups.com >> Date: Mon, 5 Dec 2011 22:27:48 -0800 (PST) >> Subject: Re: Single key press >> On Tuesday, December 6, 2011 1:49:55 PM UTC+8, Sergi Pasoev wrote: >>> Hi. >>> >>> I wonder if it is realistic to get a single key press in Python >>> without ncurses or >>> any similar library. In single key press I mean something like j and k >>> in Gnu less >>> program, you press the key and and it is captured by the script without >>> need to >>> press enter afterwards >> >> Sounds like the fast key searching for a list in the DOS application in the >> old days. >> >> This is easy in GUI of just tens of items, but for thousands of items such >> as in a directory listing, some API is really slow. >> >> >> >> >> >> ---------- Message transféré ---------- >> From: 88888 Dihedral <dihedral88...@googlemail.com> >> To: python-list@python.org >> Date: Mon, 5 Dec 2011 22:27:48 -0800 (PST) >> Subject: Re: Single key press >> On Tuesday, December 6, 2011 1:49:55 PM UTC+8, Sergi Pasoev wrote: >>> Hi. >>> >>> I wonder if it is realistic to get a single key press in Python >>> without ncurses or >>> any similar library. In single key press I mean something like j and k >>> in Gnu less >>> program, you press the key and and it is captured by the script without >>> need to >>> press enter afterwards >> >> Sounds like the fast key searching for a list in the DOS application in the >> old days. >> >> This is easy in GUI of just tens of items, but for thousands of items such >> as in a directory listing, some API is really slow. >> >> >> >> >> >> ---------- Message transféré ---------- >> From: Rainer Grimm <r.gr...@science-computing.de> >> To: python-list@python.org >> Date: Mon, 5 Dec 2011 22:42:35 -0800 (PST) >> Subject: Re: Scope of variable inside list comprehensions? >> Hello, >> >>> try: >>> songs = [Song(id) for id in song_ids] >>> except Song.DoesNotExist: >>> print "unknown song id (%d)" % id >> that's is a bad programming style. So it will be forbidden with python 3. >> The reason is that list comprehension is a construct from the functional >> world. It's only syntactic sugar for the functions map and filter. So >> functions have to be pure functions. To say it in other words, they have to >> be side-effect free. But the python construct from above pollutes the >> namespace with name id. >> >> Greetings from Rottenburg, >> Rainer >> >> >> >> ---------- Message transféré ---------- >> From: alex23 <wuwe...@gmail.com> >> To: python-list@python.org >> Date: Mon, 5 Dec 2011 23:02:42 -0800 (PST) >> Subject: Re: Questions about LISP and Python. >> On Dec 6, 2:36 pm, Xah Lee <xah...@gmail.com> wrote: >>> The python community is full of fanatics with their drivels. >> >> You do know that you could just fuck right off and leave us to it, >> yes? >> >> In general, it's the person who is shrilly imposing their minority >> opinion on a disinterested audience that deserves the title 'fanatic'. >> >> >> >> ---------- Message transféré ---------- >> From: Matt Joiner <anacro...@gmail.com> >> To: alex23 <wuwe...@gmail.com> >> Date: Tue, 6 Dec 2011 18:54:09 +1100 >> Subject: Re: Questions about LISP and Python. >> This guy is an even better troll than that 88888 guy. His spelling is >> equally bad. His essays make some good points, but I don't see why he >> doesn't shut his trap and move on. >> >> ಠ_ಠ >> >> >> >> On Tue, Dec 6, 2011 at 6:02 PM, alex23 <wuwe...@gmail.com> wrote: >>> On Dec 6, 2:36 pm, Xah Lee <xah...@gmail.com> wrote: >>>> The python community is full of fanatics with their drivels. >>> >>> You do know that you could just fuck right off and leave us to it, >>> yes? >>> >>> In general, it's the person who is shrilly imposing their minority >>> opinion on a disinterested audience that deserves the title 'fanatic'. >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > > > ---------- Message transféré ---------- > From: alex23 <wuwe...@gmail.com> > To: python-list@python.org > Date: Tue, 6 Dec 2011 00:39:53 -0800 (PST) > Subject: Re: Single key press > On Dec 6, 3:49 pm, Sergi Pasoev <s.pas...@gmail.com> wrote: >> I wonder if it is realistic to get a single key press in Python >> without ncurses or any similar library. > > It's possible using Tkinter in the standard library: > > http://www.daniweb.com/software-development/python/code/216830 > > > > > ---------- Message transféré ---------- > From: Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> > To: python-list@python.org > Date: 06 Dec 2011 08:48:39 GMT > Subject: Re: Single key press > On Tue, 06 Dec 2011 10:19:55 +0430, Sergi Pasoev wrote: > >> Hi. >> >> I wonder if it is realistic to get a single key press in Python without >> ncurses or >> any similar library. In single key press I mean something like j and k >> in Gnu less >> program, you press the key and and it is captured by the script without >> need to press enter afterwards > > > Coincidentally, I was working on that exact function last night, so you > inspired me to put it up on the Python cookbook. This version should work > on any POSIX system such as Linux, as well as Windows. I don't know if it > will work on Macintosh. > > http://code.activestate.com/recipes/577977-get-single-keypress/ > > > > -- > Steven > > > > ---------- Message transféré ---------- > From: Nobody <nob...@nowhere.com> > To: python-list@python.org > Date: Tue, 06 Dec 2011 08:55:16 +0000 > Subject: Re: struct calcsize discrepency? > On Mon, 05 Dec 2011 00:20:32 -0800, Mark Dickinson wrote: > >>> May be, yes, but since calcsize() is returning 12 when the elements >>> are put in the other order, it would seem to be not counting such >>> padding. >> >> Indeed. That's arguably a bug in the struct module, > > There's no "arguably" about it. The documentation says: > > Native size and alignment are determined using the C compiler’s sizeof > expression. > > But given: > > struct { unsigned long long a; char b[4]; } foo; > struct { char b[4]; unsigned long long a; } bar; > > sizeof(foo) will always equal sizeof(bar). If long long is 8 bytes and has > 8-byte alignment, both will be 16. > > If you want consistency with the in-memory representation used by > C/C++ programs (and the on-disk representation used by C/C++ programs > which write the in-memory representation directly to file), use ctypes; > e.g.: > > >>> from ctypes import * > >>> class foo(Structure): > _fields_ = [ > ("a", c_ulonglong), > ("b", c_char * 4)] > > >>> sizeof(foo) > 16 > > > > > ---------- Message transféré ---------- > From: Alex Mizrahi <alex.mizr...@gmail.com> > To: python-list@python.org > Date: Tue, 06 Dec 2011 11:12:31 +0200 > Subject: Re: Questions about LISP and Python. >> >> i don't like python, and i prefer emacs lisp. The primary reason is >> that python is not functional, especially with python 3. The python >> community is full of fanatics with their drivels. In that respect, >> it's not unlike Common Lisp community and Scheme lisp community. > > > What functional programming features do you use, Xah? Last time I've checked, > you didn't care about closures. In this respect, Python is better at > functional programming than Emacs Lisp. > > Do you just like writing arbitrarily long expression? Or you think that eval > is functional? > > > > ---------- Message transféré ---------- > From: Nobody <nob...@nowhere.com> > To: python-list@python.org > Date: Tue, 06 Dec 2011 09:27:29 +0000 > Subject: Re: Backspace does not erase in stdout > On Mon, 05 Dec 2011 16:23:55 +0000, Grant Edwards wrote: > >>> Emitting "\b \b" is one very common way to do a destructive backspace. >>> Inelegant? Perhaps, but a common inelegance. >> >> That's pretty much the only way I've seen it done for the past 25 >> years. > > ... before which, it was BS-DEL-BS. > > DEL being 127 means that it punches through all of the holes on the paper > tape, causing whatever was there previously to be replaced with a DEL > character. BS-SPC-BS would only punch through one of the holes. > > > > > ---------- Message transféré ---------- > From: Hans Mulder <han...@xs4all.nl> > To: python-list@python.org > Date: Tue, 06 Dec 2011 10:28:32 +0100 > Subject: Re: Single key press > On 6/12/11 09:48:39, Steven D'Aprano wrote: >> >> On Tue, 06 Dec 2011 10:19:55 +0430, Sergi Pasoev wrote: >> >>> Hi. >>> >>> I wonder if it is realistic to get a single key press in Python without >>> ncurses or >>> any similar library. In single key press I mean something like j and k >>> in Gnu less >>> program, you press the key and and it is captured by the script without >>> need to press enter afterwards >> >> >> >> Coincidentally, I was working on that exact function last night, so you >> inspired me to put it up on the Python cookbook. This version should work >> on any POSIX system such as Linux, as well as Windows. I don't know if it >> will work on Macintosh. >> >> http://code.activestate.com/recipes/577977-get-single-keypress/ > > > It works fine on MacOS/X, but probably not on MacOS Classic. > > -- HansM > > > > > > > ---------- Message transféré ---------- > From: Nobody <nob...@nowhere.com> > To: python-list@python.org > Date: Tue, 06 Dec 2011 09:48:55 +0000 > Subject: Re: Single key press > On Tue, 06 Dec 2011 10:19:55 +0430, Sergi Pasoev wrote: > >> I wonder if it is realistic to get a single key press in Python >> without ncurses or any similar library. > > On Unix, you need to use termios.tcsetattr() to disable "canonical mode". > Otherwise, the tty driver will only pass data up to the application when > the user enters a newline or EOF. > > If you do this, you also need to handle SIGTSTP and SIGCONT, restoring the > original terminal settings on SIGTSTP (typically generated by Ctrl-Z) and > restoring the application's setting on SIGCONT. > > > > > ---------- Message transféré ---------- > From: 88888 Dihedral <dihedral88...@googlemail.com> > To: python-list@python.org > Date: Tue, 6 Dec 2011 02:16:42 -0800 (PST) > Subject: Re: Scope of variable inside list comprehensions? > On Tuesday, December 6, 2011 2:42:35 PM UTC+8, Rainer Grimm wrote: >> Hello, >> >> > try: >> > songs = [Song(id) for id in song_ids] >> > except Song.DoesNotExist: >> > print "unknown song id (%d)" % id >> that's is a bad programming style. So it will be forbidden with python 3. >> The reason is that list comprehension is a construct from the functional >> world. It's only syntactic sugar for the functions map and filter. So >> functions have to be pure functions. To say it in other words, they have to >> be side-effect free. But the python construct from above pollutes the >> namespace with name id. >> >> Greetings from Rottenburg, >> Rainer > > The list might have to grow in a careless way that might lead to a crash > in the for inside a list that can't be trapped for errors directly. > > > > > ---------- Message transféré ---------- > From: Jean-Michel Pichavant <jeanmic...@sequans.com> > To: Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> > Date: Tue, 06 Dec 2011 11:38:07 +0100 > Subject: Re: Scope of variable inside list comprehensions? > Steven D'Aprano wrote: >> >> On Mon, 05 Dec 2011 19:57:15 +0100, Jean-Michel Pichavant wrote: >> >> >>> >>> The proper way to propagate information with exceptions is using the >>> exception itself: >>> >>> try: >>> songs = [Song(_id) for _id in song_ids] >>> except Song.DoesNotExist, exc: >>> print exc >>> >> >> >> >> I'm not entirely sure that this is the proper way to propagate the >> exception. I see far to many people catching exceptions to print them, or >> worse, to print a generic, useless message like "an error occurred". >> > > [snip] > > You misread me, I was referering to passing *information* with exception (in > other words, use the exception attributes). In the example I gave, the > exception has the songId value responsible for raising the error. > I totaly second your opinion on how poor the above handler is (hmm not sure > about this grammar construct, it sounds like a Yoda sentence). > > JM > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list