Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 2:10 PM, Tim wrote: > hmm, now that you mention it, this is executing on a remote box with access > to the same file system my local calling program is on. That is, there is a > local call to an intermediate script that connects to a socket on the remote > where the abov

Re: RE Module Performance

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:01 PM, wrote: > I am pretty sure that once you have typed your 127504 > ascii characters, you are very happy the buffer of your > editor does not waste time in reencoding the buffer as > soon as you enter an €, the 125505th char. Sorry, I wanted > to say z instead of eur

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:07 PM, Steven D'Aprano wrote: > On Tue, 30 Jul 2013 14:27:10 +0100, Chris Angelico wrote: > >> for delay in 100,300,600,1000,3000,5000,1: >> if not os.path.exists(directory): break >> sleep(delay) >> >> That'll s

Re: Python script help

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:49 PM, wrote: > Hello, I am looking for a script that will be able to search an online > document (by giving the script the URL) and find all the downloadable links > in the document and then download them automatically. > I appreciate your help, > Thank you. baseurl

Re: Python script help

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 4:49 PM, wrote: > I know but I think using Python in this situation is good...is that the full > script? That script just drops out to the system and lets wget do it. So don't bother with it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Share Code: Laptop Lid State

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:06 PM, Devyn Collier Johnson wrote: > Aloha everyone! > >I attached a script that I thought I could share with everyone for your > help. This Python3 script only works on Unix systems. It prints the current > state of the lid. This can be used to make a script that pe

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 4:37 PM, Tim wrote: > Argg, this isn't the first time I've had troubles with the file system. This > is FreeBSD and NFS. I will code up a progressive delay as you mentioned (with > Steve's correction). I've used several different networked file systems, including NetBIOS

Re: Python script help

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 5:10 PM, wrote: > What if I want to use only Python? is that possible? using lib and lib2? > -- > http://mail.python.org/mailman/listinfo/python-list Sure, anything's possible. And a lot easier if you quote context in your posts. But why do it? wget is exactly what you ne

Re: RE Module Performance

2013-07-30 Thread Chris Angelico
On Tue, Jul 30, 2013 at 8:09 PM, wrote: > Matable, immutable, copyint + xxx, bufferint, O(n) > Yes, but conceptualy the reencoding happen sometime, somewhere. > The internal "ucs-2" will never automagically be transformed > into "ucs-4" (eg). But probably not on the entire document. With ev

Re: Share Code: Laptop Lid State

2013-07-31 Thread Chris Angelico
On Wed, Jul 31, 2013 at 4:05 AM, Devyn Collier Johnson wrote: > > On 07/30/2013 12:00 PM, Chris Angelico wrote: >> >> On Tue, Jul 30, 2013 at 3:06 PM, Devyn Collier Johnson >> wrote: >>> >>> Aloha everyone! >>> >>> I attached a sc

Re: RE Module Performance

2013-07-31 Thread Chris Angelico
On Wed, Jul 31, 2013 at 6:45 AM, Steven D'Aprano wrote: > if you care about minimizing every possible byte, you should > use a low-level language like C. Then you can give every character 21 > bits, and be happy that you don't waste even one bit. Could go better! Since not every character has bee

Re: Repository of non-standard modules.

2013-07-31 Thread Chris Angelico
On Wed, Jul 31, 2013 at 11:53 AM, Gabor Urban wrote: > Hi, > > I am to start a new free-time project in the next couple of weeks. I am > ready to use open accessible Python modules not wanting to reinvent the weel > :-) > Is there any repository where I can find Python modules not being part of >

Re: import syntax

2013-07-31 Thread Chris Angelico
On Mon, Jul 29, 2013 at 11:37 PM, Joshua Landau wrote: > 2d) Realise that the slow part is not what you thought it was This step is mandatory. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Script that converts between indentation and curly braces in Python code

2013-07-31 Thread Chris Angelico
On Wed, Jul 31, 2013 at 1:39 PM, Beth McNany wrote: > ok, ok, if you *really* want it, you could keep track of how many leading > spaces there are (you are using spaces, right?), and insert an open bracket > where that number increases and a closing bracket where it decreases. Of > course, as wit

Re: Script that converts between indentation and curly braces in Python code

2013-07-31 Thread Chris Angelico
On Wed, Jul 31, 2013 at 3:07 PM, Rotwang wrote: >> # Assumes spaces OR tabs but not both >> # Can't see an easy way to count leading spaces other than: >> # len(s)-len(s.lstrip()) > > > How about len(s.expandtabs()) - len(s.lstrip()) instead? Still comes to the same thing. The only diff is that t

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread Chris Angelico
On Tue, Jun 19, 2012 at 12:52 PM, wrote: > ...Python pre creates some integer constants to avoid a proliferation of > objects with the same value. > > I was interested in this and so I decided to try it out. > So that matched what I'd heard and then I did this to test the limits of it : > > And

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread Chris Angelico
On Wed, Jun 20, 2012 at 7:21 AM, wrote: > I liked your code Chris demoing the different ranges in different versions. I > tried to write something like that myself but you did it an awful lot better ! There's no guarantee that it'll prove which are and aren't cached, but it does seem to work. (

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-20 Thread Chris Angelico
On Thu, Jun 21, 2012 at 1:18 AM, wrote: > On 2012-06-17, Jon Clements wrote: >> I generally find a separate partition with an encrypted file-system >> (which is fairly straight forward on *nix systems or I think there's a >> product out there that works with Windows), is a lot easier and puts th

Re: Is python a interpreted or compiled language?

2012-06-20 Thread Chris Angelico
On Thu, Jun 21, 2012 at 10:53 AM, Dave Angel wrote: > With java, one has to explicitly compile the java code, while with > CPython, the runtime logic compiles imported modules if they're not > already compiled. Putting it another way: Java's bytecode and source code are two distinct languages, b

Re: Help me with a bytes decoding problem in python 3

2012-06-21 Thread Chris Angelico
On Fri, Jun 22, 2012 at 7:47 AM, J wrote: > \xe2\x86\xb3 This is the UTF-8 encoded form of U+21B3, which is the DOWNWARDS ARROW WITH TIP RIGHTWARDS character that you're showing. That's what the "bytecode" you're seeing is. You may be able to ask the underlying program to make its output in a cle

Re: inno setup 5.5

2012-06-21 Thread Chris Angelico
f in a source file somewhere (a misspelled import, for instance). Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me with a bytes decoding problem in python 3

2012-06-21 Thread Chris Angelico
On Fri, Jun 22, 2012 at 8:30 AM, J wrote: > I'm wondering now... the way it works is that the program is run from > a user terminal/console.  however, on the other side (after the reboot > is done) it runs via an autostart script after the user is logged in, > and thus runs outside of the terminal

Re: Why is python source code not available on github?

2012-06-23 Thread Chris Angelico
On Sun, Jun 24, 2012 at 10:16 AM, gmspro wrote: > > Why is python source code not available on github? > > Make it available on github so that we can git clone and work on source > code. It's done with Mercurial, not git, but the same can be done: hg clone http://hg.python.org/cpython ChrisA --

Re: Why is python source code not available on github?

2012-06-23 Thread Chris Angelico
On Sun, Jun 24, 2012 at 10:34 AM, gmspro wrote: > > No, > I can download as .tar.bz2, but i'm talking about using git. > git clone, git add ., git commit -a, git push is easier to keep track of > my code. Then for git pull request. Mercurial can do all that. I'm not as familiar with it as I am wi

Re: Why are these files names started with underscore?

2012-06-24 Thread Chris Angelico
On Sun, Jun 24, 2012 at 6:42 PM, gmspro wrote: > > Hi, > > I see there are some files here started with underscore(_) , is there any > convention of something for it? > > Is there any convention or something? They're private implementations of public APIs. You can ignore them as implementation de

Re: Python and Facebook

2012-06-24 Thread Chris Angelico
;s no official Python-Facebook module (afaik!!), but a quick web search for 'python facebook' should get you to the couple that I saw, and possibly others. The next question is, do you trust any of them... Good luck with that one! :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: exception problem

2012-06-24 Thread Chris Angelico
hrowing the exception. Presumably these are two methods in the same class, since you're calling it as "self.chunkLine", but beyond that, it's hard to know. Take off the try/except and let your exception go to console, that's usually the easiest thing to deal with. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: exception problem

2012-06-24 Thread Chris Angelico
On Mon, Jun 25, 2012 at 9:16 AM, Charles Hixson wrote: > But what I wanted was to catch any exception.  A problem was happening and I > had no clue as to what it was.  (It turned out to be "self is not defined". >  A silly mistake, but a real one.) > > The odd thing was that if I ran it without th

Re: exception problem

2012-06-25 Thread Chris Angelico
On Mon, Jun 25, 2012 at 5:49 PM, Steven D'Aprano wrote: > On Mon, 25 Jun 2012 09:51:15 +1000, Chris Angelico wrote: > >> Mind you, I think every programmer should spend some time debugging >> blind. > > You're a cruel, cruel man. > > I suppose next you'

Re: Py3.3 unicode literal and input()

2012-06-25 Thread Chris Angelico
On Mon, Jun 25, 2012 at 9:17 PM, jmfauth wrote: > Mea culpa. I had not my head on my shoulders. > Inputing if working fine, it returns "text" correctly. > > However, and this is something different, I'm a little > bit surprised, input() does not handle escaped characters > (\u, \U). > Workaround:

Re: exception problem

2012-06-25 Thread Chris Angelico
On Tue, Jun 26, 2012 at 1:14 AM, Charles Hixson wrote: > I read that that would happen, but "  print (sys.exc_info()[:2]) " didn't > even yield a blank line.  It must have executed, because the print statement > on the line before it executed, and there wasn't a loop or a jump (and also > executio

Re: exception problem

2012-06-26 Thread Chris Angelico
(You posted privately to me again; I hope you don't mind my responding on-list as this appears to have been merely oversight.) On Wed, Jun 27, 2012 at 5:25 AM, Charles Hixson wrote: > Only thing is, this whole mess started when I was trying to trace down and > expected error.  (Which turned out t

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-26 Thread Chris Angelico
On Wed, Jun 27, 2012 at 7:08 AM, John Nagle wrote: >    The Python 3 to MySQL connection is still a mess. > The original developer of MySQLdb doesn't want to support > Python 3. This is where I would start asking: How hard is it to migrate to another SQL database (eg Postgres)? That is, assuming

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-27 Thread Chris Angelico
On Wed, Jun 27, 2012 at 8:25 PM, Christian Tismer wrote: > I think, for the small importance of the print statement in code, it > would have made the transition easier, if python 3 was as flexible > as python 2.7, with a symmetric > > "from __past__ import print_statement" construct. > For how lo

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-27 Thread Chris Angelico
On Wed, Jun 27, 2012 at 9:24 PM, Devin Jeanpierre wrote: > On Wed, Jun 27, 2012 at 7:02 AM, Chris Angelico wrote: >> Much easier to simply say no. > > It's also easier to cease developing Python at all. > > By which I mean: just because something is hard doesn't me

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-27 Thread Chris Angelico
On Wed, Jun 27, 2012 at 11:15 PM, Christian Tismer wrote: > So what I would have done is to let it work in an imperfect way. People > then have the chance to rewrite with the print function, where it makes > sense. But old packages which need to be changed, only because they > have lots of > >    

Re: Recommend decent Computer Science books

2012-06-27 Thread Chris Angelico
On Thu, Jun 28, 2012 at 7:00 AM, David Thomas wrote: > Hi I know that this is a group about Python.  But I am just wondering if > anybody can recommend any introductory/good books on Conputer Science. Well, there are books about Python specifically. They get discussed periodically on this list,

Re: Question:Programming a game grid ...

2012-06-27 Thread Chris Angelico
On Thu, Jun 28, 2012 at 9:24 AM, David wrote: > First, you should be getting an error on > vars()[var] = Button(f3, text = "00", bg = "white") > as vars() has not been declared and it does not appear to be valid Python > syntax. It's valid syntax, but highly inadvisable. What it does is call the

Re: Question:Programming a game grid ...

2012-06-27 Thread Chris Angelico
On Thu, Jun 28, 2012 at 9:35 AM, Chris Angelico wrote: > On Thu, Jun 28, 2012 at 9:24 AM, David wrote: >> First, you should be getting an error on >> vars()[var] = Button(f3, text = "00", bg = "white") >> as vars() has not been declared and it does

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-28 Thread Chris Angelico
On Thu, Jun 28, 2012 at 7:34 PM, wrote: > On the other side, one can argue this (elegancy): > > b'a series of bytes' > u'a unicode, a series of code points' Alas, not perfectly so. A 'bytes' object and a 'unicode' object can be described that way (with 'str' an alias for one or t'other), but lit

Re: code review

2012-06-29 Thread Chris Angelico
On Fri, Jun 29, 2012 at 5:31 PM, Steven D'Aprano wrote: > Given that all code contains bugs, that's the best sort of repository! Only in the sense that a cheese shop can be lauded for its cleanliness... But I am somewhat curious to see the OP's actual code. MUDs are my personal specialty. Chris

Re: I can't send images to this mail-list

2012-06-29 Thread Chris Angelico
On Thu, Jun 28, 2012 at 9:34 PM, 梦幻草 wrote: > hi,all: >     why can't I send images to python-list@python.org?? > It's a text-only list. Post your image to some free hosting somewhere and then include a link to it in your message, or - if possible - explain your issue/quest

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 8:05 AM, Thomas Jollans wrote: > Yes. My sole point, really, is that "normally", one would expect these > two expressions to be equivalent: > > a < b < c > (a < b) < c > > This is clearly not true. Python has quite a few things like that, actually. The most noticeable for C

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney wrote: > Thomas Jollans writes: > >> My sole point, really, is that "normally", one would expect these two >> expressions to be equivalent: >> >> a < b < c >> (a < b) < c > > What norm gives you that expectation? That's not how those operators > work in

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 12:06 PM, Steven D'Aprano wrote: > You can't just arbitrarily stick parentheses around parts of expressions > and expect the result to remain unchanged. Order of evaluation matters: > > 2**3**4 != (2**3)**4 But that's because ** binds right to left. It _is_ valid to say: 2

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 1:23 PM, Steven D'Aprano wrote: > All the worse for those languages, since they violate the semantics of > mathematical notation. Not so. It simply means that booleans are nothing special. In REXX, there are no data types at all, and "1" and "0" are your booleans. In C, boo

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 2:17 PM, Steven D'Aprano wrote: > Nonsense. Of course parens change the evaluation of the expression. > That's what parens are for! The whole point of my example was that it wouldn't. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 2:07 PM, rusi wrote: > Kernighan and Ritchie admit they made a design mistake with their > operator precedences: > > http://en.wikipedia.org/wiki/C_%28programming_language%29#Criticism > The examples given there have nothing to do with the chaining of comparisons and how it

Re: code review

2012-06-30 Thread Chris Angelico
On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano wrote: > Yes, you can find specially crafted examples where adding parentheses in > certain places, but not others, doesn't change the overall evaluation of > the expression. My point was that adding parentheses around the tightest-binding operator

Re: code review

2012-07-01 Thread Chris Angelico
On Sun, Jul 1, 2012 at 4:54 PM, Steven D'Aprano wrote: > Not in English-speaking countries with a culture of writing chained > comparisons in mathematics and allowing them in natural language: > > "Rock is beaten by Paper, is beaten by Scissors". I would write that as: Rock is beaten by Paper, a

Re: code review

2012-07-01 Thread Chris Angelico
On Mon, Jul 2, 2012 at 11:28 AM, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 16:33:15 +1000, Chris Angelico wrote: > >> On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano >> wrote: >>> Yes, you can find specially crafted examples where adding parentheses

Re: hello everyone! i'm a new member from China

2012-07-02 Thread Chris Angelico
e it a good subject line, state your question clearly, and so on - you'll be fine. Welcome! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: code review

2012-07-02 Thread Chris Angelico
On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano wrote: > "c" < first_word < second_word == third_word < "x" > > I'm sure I don't have to explain what that means -- that standard chained > notation for comparisons is obvious and simple. > > In Python, you write it the normal way, as above. But some

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:57 AM, Rick Johnson wrote: > Poor Chris. That's because you've been brainwashed into believing you > must spoon feed your interpreter to get your code working correctly. > Stop applying these naive assumptions to Python code. Python knows > when you reach the end of a stat

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson wrote: > py> 1 + 3 * 4 > should ALWAYS equal 16! > > With parenthesis only used for grouping: > py> a + (b*c) + d > > Which seems like the most consistent approach to me. Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found on page 1

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 5:06 AM, Thomas Jollans wrote: > On 07/02/2012 08:22 PM, Rick Johnson wrote: >> Agreed. I wish we had one language. One which had syntactical >> directives for scoping, blocks, assignments, etc, etc... >> >> BLOCK_INDENT_MARKER -> \t >> BLOCK_DEDENT_MARKER -> \n >> STATEMENT

Re: code review

2012-07-02 Thread Chris Angelico
On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano wrote: > On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote: >> Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found >> on page 153 of the 3.5th Edition Monster Manual. > > GvR is fond of quot

Re: New member from India

2012-07-02 Thread Chris Angelico
cs.python.org/py3k/tutorial/ Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 1:50 AM, Mark Lawrence wrote: > On 03/07/2012 03:25, John O'Hagan wrote: >> >> On Tue, 3 Jul 2012 11:22:55 +1000 >> >> I agree to some extent, but as a counter-example, when I was a child there >> a subject called "Weights and Measures" which is now redundant because of >> t

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 4:27 AM, Ian Kelly wrote: > On Tue, Jul 3, 2012 at 12:18 PM, John Gordon wrote: >> As a practical matter, doesn't there have to be *some* sort of limit? >> For example if the (encrypted) password is stored in a database, you can't >> exceed the table column width. > > Hopef

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 6:13 AM, Dave Angel wrote: > On 07/03/2012 12:05 PM, Mark Lawrence wrote: >> If I go to the moon I will weigh 2st 10lb (if my sums are correct :) >> but the equivalent Frenchman will still be 86kg. I hereby put this >> forward as proof that the metric system is rubbish and w

Re: code review

2012-07-03 Thread Chris Angelico
On Wed, Jul 4, 2012 at 12:57 PM, wrote: > Well, if you waited until you had the password (however long) in a variable > before you applied your maximum limits, the DoS ship has probably sailed > already. Only because data transfer is usually more expensive than hashing. But I'd say that'll alw

Re: a problem about "print"

2012-07-04 Thread Chris Angelico
On Wed, Jul 4, 2012 at 5:28 PM, levi nie wrote: > aList=str(aList) > print aList > print aList[2] The str() function takes pretty much anything and returns a string. When you subscript a string, you get characters. It's not a list of numbers any more. (Technically str is a class, not a function,

Re: simpler increment of time values?

2012-07-04 Thread Chris Angelico
On Thu, Jul 5, 2012 at 10:29 AM, Vlastimil Brom wrote: > I'd like to ask about the possibilities to do some basic manipulation > on timestamps - such as incrementing a given time (hour.minute - > string) by some minutes. > Very basic notion of "time" is assumed, i.e. dateless, > timezone-unaware,

Re: Creating an instance when the argument is already an instance.

2012-07-05 Thread Chris Angelico
# blah blah self.asdf=arg >>> def package(arg): if isinstance(arg,_package): return arg return _package(arg) >>> a=package("Test") >>> b=package(a) >>> a is b True The leading underscore is a common convention meaning &q

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Thu, Jul 5, 2012 at 11:18 PM, Vlastimil Brom wrote: > Yes, the calculations with seconds since the Unix epoch is very > convenient for real times, but trying to make it dateless seemed to > make it more complicated for me. > > The expected output for the increments asked by Jason was already >

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 1:19 AM, Steven D'Aprano wrote: > On Thu, 05 Jul 2012 23:56:37 +1000, Chris Angelico wrote: > >> (The "magic number" 86400 is a well-known number, being seconds in a >> day. > > Does that include leap seconds? No it doesn't, hen

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 1:39 AM, Rick Johnson wrote: > On Jul 5, 10:19 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> The number of seconds in a day (true solar day) varies by between 13 and >> 30 seconds depending on the time of the year and the position of the sun. > > Indeed. Wh

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 3:06 AM, Ian Kelly wrote: > The "+ 86400" is redundant; you'll get the same answer with or without > it. There is nothing to fear from going negative when doing modulo > arithmetic, because unlike C, Python actually has well-defined > semantics regarding modulo division of

Re: Apology for OT posts

2012-07-06 Thread Chris Angelico
On Fri, Jul 6, 2012 at 3:30 PM, Simon Cropper wrote: > bet this kills the conservation though... Probably. Until someone trolls the list again and sets us all going... I'm another of the worst perps, so in the words of Pooh-Bah, "I desire to associate myself with that expression of regret". It

Re: stuck in files!!

2012-07-06 Thread Chris Angelico
On Sat, Jul 7, 2012 at 4:21 AM, Alex wrote: > Chirag B wrote: > >> i want to kno how to link two applications using python for eg:notepad >> txt file and some docx file. like i wat to kno how to take path of >> those to files and run them simultaneously.like if i type something in >> notepad it ha

Re: how to compile pygtk in python2.7?

2012-07-07 Thread Chris Angelico
On Sun, Jul 8, 2012 at 2:47 PM, contro opinion wrote: > 3.PYTHON=/usr/bin/python2.7 ./configure --prefix=/usr > 4. make > 5. make install What happened when you typed these commands? Were there failure messages? As Benjamine suggested, do you need to become root to install? ChrisA -- http://ma

Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Sun, Jul 8, 2012 at 3:42 PM, wrote: > Thanks for pointing out the mistakes. Your points are right. So I am trying > to revise it, > > file_open=open("/python32/doc1.txt","r") > for line in file_open: > line_word=line.split() > print (line_word) Yep. I'd be inclined to renam

Re: how to compile pygtk in python2.7?

2012-07-08 Thread Chris Angelico
On Sun, Jul 8, 2012 at 6:26 PM, contro opinion wrote: > it's so strange > when i input > hisroty > > 506 cd /home/tiger/pygtk-2.24.0 > 507 PYTHON=/usr/local/bin/python2.7 ./configure --prefix=/usr > 508 echo $? #i get 0 ,it means success?? > 509 make > 510 echo $? #

Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Mon, Jul 9, 2012 at 3:05 AM, wrote: > On Sunday, July 8, 2012 1:33:25 PM UTC+5:30, Chris Angelico wrote: >> On Sun, Jul 8, 2012 at 3:42 PM, wrote: >> > file_open=open("/python32/doc1.txt","r") >> Also, as has already been mentioned: keepi

Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Mon, Jul 9, 2012 at 4:17 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> open("doc1.txt","r") >> >> Python will look for a file called doc1.txt in the directory you run >> the script from (which is often going to be the

Re: Discussion on some Code Issues

2012-07-09 Thread Chris Angelico
On Mon, Jul 9, 2012 at 10:57 AM, Steven D'Aprano wrote: > On Mon, 09 Jul 2012 07:54:47 +1000, Chris Angelico wrote: > >> It's like >> the difference between reminder text on a Magic: The Gathering card and >> the actual entries in the Comprehensive Rules.

Re: Discussion on some Code Issues

2012-07-09 Thread Chris Angelico
On Mon, Jul 9, 2012 at 10:24 PM, Steven D'Aprano wrote: > But it does depend on context. Sometimes you need more detail than just > "Python looks". You need to know precisely *how* Python looks, and how it > decides whether it has found or not. Agreed. So, looking back at the original context: A

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-09 Thread Chris Angelico
On Tue, Jul 10, 2012 at 3:49 AM, Rick Johnson wrote: > ALL event handlers should marked as *event > handlers* using a prefix. I like to use the prefix "evt". Some people > prefer other prefixes. In any case, just remember to be consistent. > Also, event handler names should reflect WHAT event they

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Tue, Jul 10, 2012 at 3:08 PM, Shambhu Rajak wrote: > I agree with Christian, a developer should have hobbies other than computer > stuffs. Versatile environment give more > Ability to think differently. > I like playing guitar :-) Music and programming do go VERY well together. My hobbies inc

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 1:55 AM, BartC wrote: > There's also the risk of mixing up software created at home, with that done > at work, with all the intellectual property issues that might arise. You just make the matter clear from the beginning, for instance: what's done at work stays at work, an

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 2:34 AM, Steven D'Aprano wrote: > Of course, if they try to sell themselves as having > five years experience with Python 3.2... ... then they've been borrowing Guido's time machine for personal purposes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 2:51 AM, Steven D'Aprano wrote: > If only that were true. I know quite a few people who looked the > interviewer straight in the eye and told the most bare-faced lies without > a trace of shame, and got the job. Ten years on, at least one of them is > making something aroun

Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-12 Thread Chris Angelico
On Thu, Jul 12, 2012 at 3:35 PM, Andreas Perstinger wrote: > Do you mean this license?: > http://packages.python.org/PollyReports/license.html > > It's the standard license for NetBSD projects and approved by OSI: > http://www.opensource.org/licenses/bsd-license.php > > and GPL-compatible: > http:

Re: How to safely maintain a status file

2012-07-12 Thread Chris Angelico
On Fri, Jul 13, 2012 at 11:20 AM, Rick Johnson wrote: > On Jul 12, 2:39 pm, Christian Heimes wrote: >> Windows's file system layer is not POSIX compatible. For example >> you can't remove or replace a file while it is opened by a process. > > Sounds like a reasonable fail-safe to me. POSIX says

Re: How to safely maintain a status file

2012-07-12 Thread Chris Angelico
On Fri, Jul 13, 2012 at 2:26 PM, wrote: > On Thursday, July 12, 2012 10:13:47 PM UTC-5, Steven D'Aprano wrote: >> Rick has obviously never tried to open a file for reading when somebody >> else has it opened, also for reading, and discovered that despite Windows >> being allegedly a multi-user op

Re: code review

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 1:04 AM, Steven D'Aprano wrote: > Actually, no. Is True less than False, or is it greater? In boolean > algebra, the question has no answer. It is only an implementation detail > of Python that chooses False < True. Maybe in boolean algebra, but in code, it's handy to have

Re: adding a simulation mode

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 3:08 AM, Prasad, Ramit wrote: > I would say the opposite. In production code usually I want it > to recover, log as much information as I need (including sending > any notifications), and NOT just die. > > In development, not catching the exception will give me a full > tra

Re: lambda in list comprehension acting funny

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 2:46 AM, rusi wrote: > Ok let me restate: if python were to work that way (without the > global) we could say either > a Python chooses to have dynamic scoping of variables > or > b There is a bug in python's scoping rules Or c, there's a declaration at the top: from __fu

Re: [Python] RE: How to safely maintain a status file

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 3:59 AM, Prasad, Ramit wrote: > I lean slightly towards the POSIX handling with the addition that > any additional write should throw an error. You are now saving to > a file that will not exist the moment you close it and that is probably > not expected. There are several

Re: howto do a robust simple cross platform beep

2012-07-14 Thread Chris Angelico
On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer wrote: > I, too, would find it useful -- for me (although I do not hate myself). > > Surely, you know an alarm clock. Usually, it gives an audible signal > when it is time to do something. A computer can in principle be used > as a flexible alarm cloc

Re: lambda in list comprehension acting funny

2012-07-14 Thread Chris Angelico
On Sun, Jul 15, 2012 at 9:29 AM, Steven D'Aprano wrote: > Not necessarily *compile* time, but the distinction is between when the > function is defined (which may at compile time, or it may be at run time) > versus when the function is called. I'd treat the def/lambda statement as "compile time"

Re: howto do a robust simple cross platform beep

2012-07-14 Thread Chris Angelico
On Sun, Jul 15, 2012 at 10:39 AM, Hans Mulder wrote: > The other prerequisite is that the use is physically near the > compueter where your Python process is running. > > If, for exmple, I'm ssh'ed into my webserver, then sending a sound > file to the server's speaker may startle someone in the da

Re: lambda in list comprehension acting funny

2012-07-15 Thread Chris Angelico
On Sun, Jul 15, 2012 at 6:32 PM, Steven D'Aprano wrote: > At compile time, Python parses the source code and turns it into byte- > code. Class and function definitions are executed at run time, the same > as any other statement. Between the parse step and the 'def' execution, a code object is cre

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Chris Angelico
On Sun, Jul 15, 2012 at 6:34 PM, Andrew Berg wrote: > Converting 0 and 1 to False and True seems reasonable, but I don't see > the point in converting other arbitrary values. It's for convenience. Unfortunately, not all languages treat all types the same way. It's very handy, though, to be able t

Re: Keeping the Console Open with IDLE

2012-07-15 Thread Chris Angelico
On Mon, Jul 16, 2012 at 1:35 AM, wrote: > Besides, you can skip most of those steps by Shift+RightClicking the file > icon and choosing "Open Command Window Here". That's not standard. Me, I can invoke git bash anywhere I want it, but that doesn't mean I'd recommend installing git just so that

Re: Keeping the Console Open with IDLE

2012-07-15 Thread Chris Angelico
On Mon, Jul 16, 2012 at 2:19 AM, Rick Johnson wrote: > On Sunday, July 15, 2012 10:57:00 AM UTC-5, Chris Angelico wrote: >> On Mon, Jul 16, 2012 at 1:35 AM, wrote: >> > Besides, you can skip most of those steps by Shift+RightClicking >> > the file icon and choosin

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Chris Angelico
On Mon, Jul 16, 2012 at 4:56 AM, Rick Johnson wrote: > On Sunday, July 15, 2012 1:01:58 PM UTC-5, Ian wrote: > >> So now instead of having to understand how "if" handles arbitrary >> values, we have to understand how "bool" handles arbitrary values. >> How is that an improvement? > > Because we ar

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Chris Angelico
On Mon, Jul 16, 2012 at 11:21 AM, Ranting Rick wrote: > If HOWEVER we want to "truth test" an object (as in: "if obj") we > should be FORCED to use the bool! Why? Because explicit is better than > implicit and readability counts if we want to create maintainable code > bases! > > if bool(obj) and

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Chris Angelico
On Mon, Jul 16, 2012 at 12:41 PM, Ranting Rick wrote: > On Jul 15, 9:13 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > >> I have just written a bunch of code with about two dozen examples similar >> to this: >> >> for item in (seq or []): >> do_something_with(item) > > Short ci

<    3   4   5   6   7   8   9   10   11   12   >