Re: functions, list, default parameters

2010-10-29 Thread Gregory Ewing
Steven D'Aprano wrote: And how does Python know whether some arbitrary default object is mutable or not? It doesn't, that's the whole point. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: embarrassing class question

2010-10-29 Thread Gregory Ewing
Paul Rudin wrote: Gregory Ewing writes: You can clean up dir() by defining __all__ as a list of names that you want to officially export. I'm not sure that's necessarily a good idea... when you're trying to figure out why something behaves in a certain way you want to check for the presence

Re: A question I have...

2010-10-29 Thread Steven D'Aprano
On Sat, 30 Oct 2010 15:05:37 +1300, Lawrence D'Oliveiro wrote: > In message , geremy > condra wrote: > >> ... dividing strings by a number doesn't make sense. > > The logical meaning would be the opposite of multiplying strings by a > number: > > >>> "abc" * 3 > 'abcabcabc' > >>> "ab

Re: factorial of negative one (-1)

2010-10-29 Thread Bj Raz
Thank you Robert for the clarification. Since I'm an amateur programmer, could you please give me a sample of how I would do it. I'll take some time to study arrays as well, and how to write them, I know of lists, and tuples, and dictionaries; from "Dive into Python". but I am very green around t

Re: embarrassing class question

2010-10-29 Thread Lawrence D'Oliveiro
In message <8idvgaf21...@mid.individual.net>, Peter Pearson wrote: > Yes, module w imports x, and therefore w.x exists. Is that bad? No-one seems to have come out and said this yet (unless it was in one of those messages that no longer seem to be accessible on my ISP’s news server): Python has

Re: curses and processing terminal escape characters

2010-10-29 Thread Lawrence D'Oliveiro
In message , Tim Harig wrote: > Python could easily process the escape codes for any given terminal; but, > in general, you would want something that works for more then a single > terminal type. Does anyone still bother with anything other than VT1xx-type terminals? -- http://mail.python.org/ma

Re: Generating PDF file in Python

2010-10-29 Thread Lawrence D'Oliveiro
In message , Ed Keith wrote: > I need to generate PDF files and I'm exploring what tools to use. I was > planing on using ReportLab, but recently found some references to pango > (http://www.pango.org/) and ciaro (http://cairographics.org/) being able > to generate PDF files. But am having difficu

Re: downcasting problem

2010-10-29 Thread Lawrence D'Oliveiro
In message , Nikola Skoric wrote: > I have a file full of lines which I parse into Line objects. I also > have two subclasses of Line, namely Individual and Family. Constructor > of both subclasses needs all Line objects in the file to be > constructed, so I cannot construct subclass objects in th

Re: str(int_var) formatted

2010-10-29 Thread John Yeung
On Oct 29, 11:59 am, Tracubik wrote: > i've to convert integer x to string, but if x < 10, > the string have to be '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' Everyone else seems to prefer the format-based solutions, which is fine. I will give zfill a little exposure,

Re: Land Of Lisp is out

2010-10-29 Thread namekuseijin
On 29 out, 19:06, Alessio Stalla wrote: > On 28 Ott, 10:42, p...@informatimago.com (Pascal J. Bourguignon) > wrote: > > > sthueb...@googlemail.com (Stefan Hübner) writes: > > >> Would it be right to say that the only Lisp still in common use is the > > >> Elisp > > >> built into Emacs? > > > > Cl

Re: ftplib - Did the whole file get sent?

2010-10-29 Thread Lawrence D'Oliveiro
In message <4cc5d9e9$0$1661$742ec...@news.sonic.net>, John Nagle wrote: > Look at sock_close in "socketmodule.c". Note that it ignores the > return status on close, always returns None, and never raises an > exception. As the Linux manual page for "close" says: > "Not checking the return val

Re: Tools for turning Python code into XMI?

2010-10-29 Thread Lawrence D'Oliveiro
In message <4cc3fad1.5080...@sschwarzer.net>, Stefan Schwarzer wrote: > I'm looking for a tool which can read Python files and write > a corresponding XMI file for import into UML tools. UML ... isn’t that something more in vogue among the Java/DotNet corporate- code-cutter-drone crowd? Specific

Re: A question I have...

2010-10-29 Thread Lawrence D'Oliveiro
In message , geremy condra wrote: > ... dividing strings by a number doesn't make sense. The logical meaning would be the opposite of multiplying strings by a number: >>> "abc" * 3 'abcabcabc' >>> "abcabcabc" // 3 'abc' >>> "abcabcabc" // "abc" 3 >>> "abcabcabd" //

Re: MATLAB:matplotlib::Mathematica::???

2010-10-29 Thread Lawrence D'Oliveiro
In message , kj wrote: > matplotlib, even in its underlying so-called "OO mode", follows > MATLAB's graphics model, which, in my very subjective opinion, is > vastly inferior to Mathematica's. Speaking as someone who once had to do GUI programming in MATLAB, I think it’s really only good for one

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-29 Thread Lawrence D'Oliveiro
In message , Dave Angel wrote: > Gee, maybe when "you're trying to track down problems", you might try > starting the application in a console? On a rationally-designed OS, I have a choice. I can do that, but that’s not really my first resort: the first thing I can do is check in ~/.xsession- e

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-29 Thread Lawrence D'Oliveiro
In message <8ivfa3fif...@mid.individual.net>, Gregory Ewing wrote: > Lawrence D'Oliveiro wrote: > >> You mean “GUI console”. So non-GUI apps get a GUI element whether they >> want it or not, while GUI ones don’t. That’s completely backwards. > > The "G" in GUI stands for "Graphical". I wouldn't

Re: Runtime error

2010-10-29 Thread John Machin
On Oct 29, 3:26 am, Sebastian wrote: > Hi all, > > I am new to python and I don't know how to fix this error. I only try to > execute python (or a cgi script) and I get an ouptu like > > [...] > 'import site' failed; traceback: > Traceback (most recent call last): > File "/usr/lib/python2.6/site.p

RE: Python 2.7 or 3.1

2010-10-29 Thread Braden Faulkner
I personally would take only one bite at a time. Meaning only do one then do the other later. But to each it own :) > Date: Fri, 29 Oct 2010 17:48:11 -0500 > To: python-list@python.org > From: jbiq...@icsmx.com > Subject: Re: Python 2.7 or 3.1 > > Hello all > > Would you consider a "not so in

Re: Runtime error

2010-10-29 Thread Peter Pearson
On Thu, 28 Oct 2010 18:26:49 +0200, Sebastian wrote: > Hi all, > > I am new to python and I don't know how to fix this error. I only try to > execute python (or a cgi script) and I get an ouptu like > > [...] > 'import site' failed; traceback: > Traceback (most recent call last): > File "/usr/lib

Re: multiprocessing signal defect

2010-10-29 Thread Neal Becker
Antoine Pitrou wrote: > On Fri, 29 Oct 2010 08:12:19 -0400 > Neal Becker wrote: >> Seems multiprocessing doesn't behave well with signals: >> [...] > > By the way, could you post an issue on the tracker with instructions on > how to reproduce (including OS)? > > Thanks > > Antoine. http://bug

Re: Exception Handling in Python 3

2010-10-29 Thread Greg Ewing
Chris Rebert wrote: On Fri, Oct 29, 2010 at 2:30 AM, Gregory Ewing wrote: I think what's disturbing about this is that the two halves of the extended traceback are printed in the wrong order. We're True, but swapping the order would only worsen Steve's problem. Yes, I can see that what S

Re: Python 2.7 or 3.1

2010-10-29 Thread Jorge Biquez
Hello all Would you consider a "not so intelligent move" for a newsbie to Python to have maybe version 2.7 and 3.x (if that's possible to be running together on the same machine) to have them run and be learning mainly in 2.7 and see differences in 3.x? In my case I am interested mainly in we

Re: Python 2.7 or 3.1

2010-10-29 Thread geremy condra
On Wed, Oct 27, 2010 at 7:18 PM, Braden Faulkner wrote: > Would it be safe to say that 2.6 would be even better for beginners than? Let me just come out with a contrary point of view before you go down that path. If you're seriously considering using sqlite, then you may be just as well off using

Re: Python 2.7 or 3.1

2010-10-29 Thread Christian Heimes
Am 29.10.2010 23:16, schrieb Lawrence D'Oliveiro: > In message , Jorge > Biquez wrote: > >> I was wondering if you can comment more about what alternatives to >> use instead to MySql. My web solutions do not need "all the power" of >> a true database, > > Is more than one process likely to acces

Re: Python 2.7 or 3.1

2010-10-29 Thread Lawrence D'Oliveiro
In message , Jorge Biquez wrote: > I was wondering if you can comment more about what alternatives to > use instead to MySql. My web solutions do not need "all the power" of > a true database, Is more than one process likely to access the data at the same time? If so, use MySQL. -- http://mail

Re: multiprocessing signal defect

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 08:12:19 -0400 Neal Becker wrote: > Seems multiprocessing doesn't behave well with signals: > [...] By the way, could you post an issue on the tracker with instructions on how to reproduce (including OS)? Thanks Antoine. -- http://mail.python.org/mailman/listinfo/python-l

Re: is list comprehension necessary?

2010-10-29 Thread Lawrence D'Oliveiro
In message <4cc701e7$0$1606$742ec...@news.sonic.net>, John Nagle wrote: > The weird "functional if" syntax additions were a cave-in to the > functional crowd, and may have been a mistake. The only mistake was not putting functional-if into the language in the first place, and having to use that

Re: Python changes

2010-10-29 Thread Hans-Peter Jansen
On Thursday 28 October 2010, 21:23:03 Craig McRoberts wrote: > Oh, I like to browse brick-and-mortar enough. But it's been forever > since I've bought something there. If you can get your hands on a copy of Mark Summerfield's Programming in Python3, check it out. He really raised the accustomed q

Are Tkinter StringVar (IntVar, etc) thread safe?

2010-10-29 Thread python
Are Tkinter StringVar (IntVar, FloatVar, etc) thread safe, eg. can a background thread read or write to these objects? Or must I use a Queue to pass information between my background thread and my main Tkinter GUI thread and have my main Tkinter thread pop the Queue and update the application's Str

Re: is list comprehension necessary?

2010-10-29 Thread Lawrence D'Oliveiro
In message , Andre Alexander Bell wrote: >>>> i = 5 >>>> l = [i**2 for i in range(3)] >>>> i >2 The last line comes out as 5 in Python 3.1. -- http://mail.python.org/mailman/listinfo/python-list

Re: Land Of Lisp is out

2010-10-29 Thread Alessio Stalla
On 28 Ott, 10:42, p...@informatimago.com (Pascal J. Bourguignon) wrote: > sthueb...@googlemail.com (Stefan Hübner) writes: > >> Would it be right to say that the only Lisp still in common use is the > >> Elisp > >> built into Emacs? > > > Clojure (http://clojure.org) is a Lisp on the JVM. It's gai

Re: Land Of Lisp is out

2010-10-29 Thread Lawrence D'Oliveiro
In message , jos...@corporate-world.lisp.de wrote: > On 29 Okt., 01:34, Lawrence D'Oliveiro > wrote: > >> In message >> , >> kodifik wrote: >> >>> On Oct 28, 1:55 am, Lawrence D'Oliveiro >>> wrote: >> Would it be right to say that the only Lisp still in common use is the Elisp built i

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-29 Thread Stefan Behnel
Dun Peal, 28.10.2010 09:10: I find myself surprised at the relatively little use that Cython is seeing. I don't think it's being used that little. It just doesn't show that easily. We get a lot of feedback on the mailing list that suggests that it's actually used by all sorts of people in all

Re: functions, list, default parameters

2010-10-29 Thread Dan Stromberg
On Thu, Oct 21, 2010 at 7:53 PM, John Nagle wrote: > On 10/21/2010 2:51 PM, Chris Rebert wrote: > >> On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote: >> >>> I found two similar questions in the mailing list, but I didn't >>> understand >>> >>> the explanations. >>> I ran this code on Ubuntu 10.

Re: Calling a method from invoking module

2010-10-29 Thread Dave Angel
On 2:59 PM, Chris Rebert wrote: On Thu, Oct 28, 2010 at 8:33 PM, Baskaran Sankaran wrote: Sorry for the confusion; fooz(), track() and barz() are all members of their respective classes. I must have missed the self argument while creating the synthetic example. Yeah, I realize the mutual impor

Re: Exception Handling in Python 3

2010-10-29 Thread Ethan Furman
MRAB wrote: On 29/10/2010 11:24, Chris Rebert wrote: On Fri, Oct 29, 2010 at 2:30 AM, Gregory Ewing wrote: Chris Rebert wrote: Your Traceback is merely being made slightly longer/more complicated than you'd prefer; however, conversely, what if a bug was to be introduced into your exception

Re: curses and processing terminal escape characters

2010-10-29 Thread Dan Stromberg
On Fri, Oct 29, 2010 at 10:35 AM, Tim Harig wrote: > On 2010-10-29, mix wrote: > > Hi, > > > > I'm wondering if there is a way in python to process a string > > containing terminal escape characters. Example: Please consider the > > following string: > > Python could easily process the escape co

Re: Exception Handling in Python 3

2010-10-29 Thread Ethan Furman
MRAB wrote: On 24/10/2010 13:28, Steve Holden wrote: On 10/24/2010 4:48 AM, Martin v. Loewis wrote: Am 24.10.2010 07:01, schrieb Steve Holden: I was somewhat surprised to discover that Python 3 no longer allows an exception to be raised in an except clause (or rather that it reports it as a s

Re: Exception Handling in Python 3

2010-10-29 Thread MRAB
On 24/10/2010 13:28, Steve Holden wrote: On 10/24/2010 4:48 AM, Martin v. Loewis wrote: Am 24.10.2010 07:01, schrieb Steve Holden: I was somewhat surprised to discover that Python 3 no longer allows an exception to be raised in an except clause (or rather that it reports it as a separate except

Re: curses and processing terminal escape characters

2010-10-29 Thread Tim Harig
On 2010-10-29, mix wrote: > Hi, > > I'm wondering if there is a way in python to process a string > containing terminal escape characters. Example: Please consider the > following string: Python could easily process the escape codes for any given terminal; but, in general, you would want somethin

Re: str(int_var) formatted

2010-10-29 Thread MRAB
On 29/10/2010 17:18, "none <"@mail.python.org wrote: On 29/10/10 16:59, Tracubik wrote: Hi all, i've to convert integer x to string, but if x< 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can

Re: Exception Handling in Python 3

2010-10-29 Thread MRAB
On 29/10/2010 11:24, Chris Rebert wrote: On Fri, Oct 29, 2010 at 2:30 AM, Gregory Ewing wrote: Chris Rebert wrote: Your Traceback is merely being made slightly longer/more complicated than you'd prefer; however, conversely, what if a bug was to be introduced into your exception handler? Then

Re: DateTime object

2010-10-29 Thread jf
Le 29/10/2010 13:41, Adam Tauno Williams a écrit : So what kind of object is ? In this case it is clearly mx.DateTime.DateTime. __repr__ and __str__ may produce different representations; Thanks a lot, in fact it is DateTime from xmlrpclib but your post really helped me to find it. -- htt

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread cbr...@cbrownsystems.com
On Oct 29, 2:43 am, Steven D'Aprano wrote: > On Thu, 28 Oct 2010 09:16:42 -0700, cbr...@cbrownsystems.com wrote: > > It's clear but tedious to write: > > > if 'monday" in days_off or "tuesday" in days_off: > >     doSomething > > > I currently am tending to write: > > > if any([d for d in ['monday

RE: str(int_var) formatted

2010-10-29 Thread Andreas Tawn
> Hi all, > i've to convert integer x to string, but if x < 10, the string have to > be > '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' > > x = 32 > str(x) --> '32' > > x represent hour/minute/second. > > I can easily add '0' with a if then block, but is there a built

Re: str(int_var) formatted

2010-10-29 Thread none
On 29/10/10 16:59, Tracubik wrote: Hi all, i've to convert integer x to string, but if x< 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can easily add '0' with a if then block, but is there

Re: str(int_var) formatted

2010-10-29 Thread Grant Edwards
On 2010-10-29, Tracubik wrote: > Hi all, > i've to convert integer x to string, but if x < 10, the string have to be > '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' > > x = 32 > str(x) --> '32' > > x represent hour/minute/second. > > I can easily add '0' with a if then b

str(int_var) formatted

2010-10-29 Thread Tracubik
Hi all, i've to convert integer x to string, but if x < 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can easily add '0' with a if then block, but is there a built-in way to add the '0' automat

Re: Exception Handling in Python 3

2010-10-29 Thread rantingrick
On Oct 24, 7:36 am, Steve Holden wrote: > I don't want people to think this is a big deal, however. Nonsense, this IS a big deal. (and Steve grow a spine already!) I was not even aware of this issue until you brought it up -- although i will admit your choice of title is completely misleading!

Re: Python changes

2010-10-29 Thread rantingrick
On Oct 28, 2:16 pm, Teenan wrote: > hmmm bookstore.. those are the things they had before Amazon right? ;) hmm Amazon... Is that the place where you buy tutorials when you could instead get the same info for free with a little Google fu? ;-) -- http://mail.python.org/mailman/listinfo/python-li

curses and processing terminal escape characters

2010-10-29 Thread mix
Hi, I'm wondering if there is a way in python to process a string containing terminal escape characters. Example: Please consider the following string: str = ''\x1B[K\x1B[D\x1B[D\x1B[D\x1B[D\x1B[C\x1B[C\x1B[C\x1B[C \x1b[d\x1b[d\x...@q\x1b[@q\x...@q'' as a result of printing it (print str), t

Re: factorial of negative one (-1)

2010-10-29 Thread Robert Kern
On 10/29/10 12:02 AM, Chris Rebert wrote: On Thu, Oct 28, 2010 at 9:41 PM, Bj Raz wrote: I am working with differential equations of the higher roots of negative one. (dividing enormous numbers into other enormous numbers to come out with very reasonable numbers). I am mixing this in to a scrip

Re: multiprocessing signal defect

2010-10-29 Thread Adam Tauno Williams
On Fri, 2010-10-29 at 07:31 -0700, Jean-Paul Calderone wrote: > On Oct 29, 10:08 am, Adam Tauno Williams > wrote: > > signal handler to do something smart in the case of a "-15" [for which > > there isn't really a thread equivalent - can you sent a SystemV style > > signal to an individual thread

Re: Suppressing __context__

2010-10-29 Thread Martin v. Loewis
> It is not easily discoverable, but it is possible to suppress > __context__ by using a bare re-raise afterwards: I see. I'd wrap this like this: def raise_no_context(e): try: raise e except: e.__context__=None raise d = {} try: val = d['nosuch'] except KeyEr

Re: multiprocessing signal defect

2010-10-29 Thread Jean-Paul Calderone
On Oct 29, 10:08 am, Adam Tauno Williams wrote: > signal handler to do something smart in the case of a "-15" [for which > there isn't really a thread equivalent - can you sent a SystemV style > signal to an individual thread in a process?  I don't think so.] Yes. pthread_kill(P) Jean-Paul --

Re: multiprocessing signal defect

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 10:08:01 -0400 Adam Tauno Williams wrote: > > No, I don't think so. You're asking the module to over generalize > behavior. Reaping of the child is important, and that the child needs > to be reaped may matter to the master child (why? did something go > wrong?). Silently r

Re: multiprocessing signal defect

2010-10-29 Thread Adam Tauno Williams
On Fri, 2010-10-29 at 08:39 -0400, Neal Becker wrote: > Adam Tauno Williams wrote: > > > On Fri, 2010-10-29 at 08:12 -0400, Neal Becker wrote: > >> Seems multiprocessing doesn't behave well with signals: > >> - > >> from multiprocessing import Pool > >> import time > >> def sleep (dummy):

Re: multiprocessing signal defect

2010-10-29 Thread Neal Becker
Adam Tauno Williams wrote: > On Fri, 2010-10-29 at 08:12 -0400, Neal Becker wrote: >> Seems multiprocessing doesn't behave well with signals: >> - >> from multiprocessing import Pool >> import time >> def sleep (dummy): >> time.sleep (10) >> if __name__ == '__main__': >> pool = Poo

Re: multiprocessing signal defect

2010-10-29 Thread Adam Tauno Williams
On Fri, 2010-10-29 at 08:12 -0400, Neal Becker wrote: > Seems multiprocessing doesn't behave well with signals: > - > from multiprocessing import Pool > import time > def sleep (dummy): > time.sleep (10) > if __name__ == '__main__': > pool = Pool (processes=2) > result = po

multiprocessing signal defect

2010-10-29 Thread Neal Becker
Seems multiprocessing doesn't behave well with signals: --- from multiprocessing import Pool import time def sleep (dummy): time.sleep (10) if __name__ == '__main__': pool = Pool (processes=2) result = pool.map (sleep, range (4)) - start it up $ python t

Re: Suppressing __context__

2010-10-29 Thread Antoine Pitrou
On Fri, 29 Oct 2010 04:07:15 -0700 Chris Rebert wrote: > On Fri, Oct 29, 2010 at 4:02 AM, Antoine Pitrou wrote: > > On Sun, 24 Oct 2010 10:48:23 +0200 > > "Martin v. Loewis" wrote: > >> > >> You may now wonder whether it is possible to set __context__ to None > >> somehow. See PEP 3134: > >> >

Re: DateTime object

2010-10-29 Thread Adam Tauno Williams
On Fri, 2010-10-29 at 13:15 +0200, jf wrote: > Hi, > I've a bug in my code and I'm trying de reproduce it. > To trace the bug I print arguments, and it produces this: > {'date': } > My question is: what is: ? > I use mx.DateTime put if I print it I get: > > So what kind of object is ? In this c

Re: DateTime object

2010-10-29 Thread Luca Bel
Take a look here: http://pypi.python.org/pypi/DateTime/ I always use this package only with Zope (it's an application server) If you are simply working in python maybe it's better to use datetime object. Hi. On Fri, Oct 29, 2010 at 1:15 PM, jf wrote: > Hi, > > I've a bug in my code and I'm tr

DateTime object

2010-10-29 Thread jf
Hi, I've a bug in my code and I'm trying de reproduce it. To trace the bug I print arguments, and it produces this: {'date': } My question is: what is: ? I use mx.DateTime put if I print it I get: So what kind of object is ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Suppressing __context__

2010-10-29 Thread Chris Rebert
On Fri, Oct 29, 2010 at 4:02 AM, Antoine Pitrou wrote: > On Sun, 24 Oct 2010 10:48:23 +0200 > "Martin v. Loewis" wrote: >> >> You may now wonder whether it is possible to set __context__ to None >> somehow. See PEP 3134: >> >> Open Issue: Suppressing Context >> >>     As written, this PEP makes i

Suppressing __context__

2010-10-29 Thread Antoine Pitrou
On Sun, 24 Oct 2010 10:48:23 +0200 "Martin v. Loewis" wrote: > > You may now wonder whether it is possible to set __context__ to None > somehow. See PEP 3134: > > Open Issue: Suppressing Context > > As written, this PEP makes it impossible to suppress '__context__', > since setting exc.

Re: Exception Handling in Python 3

2010-10-29 Thread Chris Rebert
On Fri, Oct 29, 2010 at 2:30 AM, Gregory Ewing wrote: > Chris Rebert wrote: >> >> Your Traceback is merely being made slightly longer/more >> complicated than you'd prefer; however, conversely, what if a bug was >> to be introduced into your exception handler? Then you'd likely very >> much apprec

Re: ANN: PyGUI 2.3

2010-10-29 Thread Gregory Ewing
Daniel Fetchinson wrote: Any reason your project is not easy_installable? Mainly because I'm not a setuptools user and haven't been motivated to learn how to do this so far. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: PyGUI 2.3

2010-10-29 Thread Gregory Ewing
Daniel Fetchinson wrote: The problem is that some part of the application gets installed to /home/fetchinson/.local/lib/python2.6/site-packages/GUI and some other parts get installed to /home/fetchinson/.local/lib/python/site-packages/GUI Which parts get installed in which places, exactly?

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Adam Przybyla
cbr...@cbrownsystems.com wrote: > It's clear but tedious to write: > > if 'monday" in days_off or "tuesday" in days_off: >doSomething > > I currently am tending to write: > > if any([d for d in ['monday', 'tuesday'] if d in days_off]): >doSomething > > Is there a better pythonic idiom

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Steven D'Aprano
On Thu, 28 Oct 2010 09:16:42 -0700, cbr...@cbrownsystems.com wrote: > It's clear but tedious to write: > > if 'monday" in days_off or "tuesday" in days_off: > doSomething > > I currently am tending to write: > > if any([d for d in ['monday', 'tuesday'] if d in days_off]): > doSomething

Re: Exception Handling in Python 3

2010-10-29 Thread Gregory Ewing
Chris Rebert wrote: Your Traceback is merely being made slightly longer/more complicated than you'd prefer; however, conversely, what if a bug was to be introduced into your exception handler? Then you'd likely very much appreciate the "superfluous" Traceback info. I think what's disturbing abo

Re: How on Factorial

2010-10-29 Thread Steven D'Aprano
On Thu, 28 Oct 2010 10:13:15 -0400, Dave Angel wrote: > Inverting the bits of a floating point number wouldn't make much sense, > so fortunately it gives an error. >>> from struct import pack, unpack >>> >>> def float_as_int(x): ... bits = pack("d", x) ... return unpack("q", bits)[0] ...

Re: Exception Handling in Python 3

2010-10-29 Thread Gregory Ewing
Steve Holden wrote: Yeah, that's a given. Ruby would probably let you do that, but Python insists that you don't dick around with the built-in types. And roghtly so, IMHO. Some restrictions on this are necessary -- it obviously wouldn't be safe to allow replacing the class of an object with on

Re: Python changes

2010-10-29 Thread Steven D'Aprano
On Thu, 28 Oct 2010 20:16:45 +0100, Teenan wrote: > On Thu, 2010-10-28 at 15:03 -0400, Craig McRoberts wrote: >> Thanks for the prompt replies. Sounds like it's time to hit a >> bookstore. >> >> Craig McRoberts > > You could do a lot worse than getting 'Dive into Python' (There's even a > nice n

Re: "Strong typing vs. strong testing" [OT]

2010-10-29 Thread Gregory Ewing
Mark Wooding wrote: Would the world be a better place if we had a name for 2 pi rather than pi itself? I don't think so. The women working in the factory in India that makes most of the worlds 2s would be out of a job. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Python changes

2010-10-29 Thread Steven D'Aprano
On Thu, 28 Oct 2010 14:14:43 -0400, Craig McRoberts wrote: > First off, greetings from a newbie! > > Here's the deal. I gained a passable knowledge of Python nearly ten > years ago. Then I decided a career in the computer sciences wasn't for > me, and I let it go. Now I find myself back in the de

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-29 Thread Gregory Ewing
gb345 wrote: I see how clicking directly on these files would obviate the need to specify the path of the interpreter, but it's still not clear to me how the interpreter would know where to look for the myscript.py module that both the GUI scripts require. If it's in the same directory as the

Re: functions, list, default parameters

2010-10-29 Thread Steven D'Aprano
On Fri, 29 Oct 2010 21:24:23 +1300, Gregory Ewing wrote: > John Nagle wrote: >> On 10/21/2010 2:51 PM, Chris Rebert wrote: > >>> This is a common newbie stumbling-block: Don't use lists (or anything >>> mutable) as default argument values > >> That really should be an error. > > No, it shou

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-29 Thread Gregory Ewing
Lawrence D'Oliveiro wrote: You mean “GUI console”. So non-GUI apps get a GUI element whether they want it or not, while GUI ones don’t. That’s completely backwards. The "G" in GUI stands for "Graphical". I wouldn't call a window that displays nothing but text "graphical". -- Greg -- http://ma

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Xavier Ho
Not sure why you use the for-else syntax without a break or continue. And I'm also not sure on the readability. -Xav on his Froyo On 29/10/2010 6:21 PM, "HEK" wrote: > On Oct 28, 6:16 pm, "cbr...@cbrownsystems.com" > wrote: >> It's clear but tedious to write: >> >> if 'monday" in days_off or "tu

Re: embarrassing class question

2010-10-29 Thread Paul Rudin
Gregory Ewing writes: > Brendan wrote: >> I use >> Python sporadically, and frequently use the dir command to learn or >> remind myself of class methods. > > You can clean up dir() by defining __all__ as a list of > names that you want to officially export. Other names will > still be there, but

Re: functions, list, default parameters

2010-10-29 Thread Gregory Ewing
John Nagle wrote: On 10/21/2010 2:51 PM, Chris Rebert wrote: This is a common newbie stumbling-block: Don't use lists (or anything mutable) as default argument values That really should be an error. No, it shouldn't. The criterion isn't whether the object is mutable, but whether you a

Re: embarrassing class question

2010-10-29 Thread Gregory Ewing
Brendan wrote: I use Python sporadically, and frequently use the dir command to learn or remind myself of class methods. You can clean up dir() by defining __all__ as a list of names that you want to officially export. Other names will still be there, but they won't show up in the dir() listing

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread HEK
On Oct 28, 6:16 pm, "cbr...@cbrownsystems.com" wrote: > It's clear but tedious to write: > > if 'monday" in days_off or "tuesday" in days_off: >     doSomething > > I currently am tending to write: > > if any([d for d in ['monday', 'tuesday'] if d in days_off]): >     doSomething > > Is there a be

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Carl Banks
On Oct 28, 10:50 pm, Paul Rubin wrote: > John Nagle writes: > >    d1 = set('monday','tuesday') > >    days_off = set('saturday','sunday') > >    if not d1.isdisjoint(days_off) :... > >    This is cheaper than intersection, since it doesn't have to > > allocate and construct a set. It just tests

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread cbr...@cbrownsystems.com
On Oct 28, 11:56 am, Arnaud Delobelle wrote: > "cbr...@cbrownsystems.com" writes: > > It's clear but tedious to write: > > > if 'monday" in days_off or "tuesday" in days_off: > >     doSomething > > > I currently am tending to write: > > > if any([d for d in ['monday', 'tuesday'] if d in days_off