Re: First python program, syntax error in while loop

2013-05-06 Thread Chris Angelico
On Mon, May 6, 2013 at 11:08 PM, Roy Smith wrote: > On the other hand, I've long since given up trying to remember operator > precedence in various languages. If I ever have even the slightest > doubt, I just go ahead and put in the extra parens. If I ever have even the slightest doubt, I just g

Re: socket programming

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 1:54 AM, Pedro wrote: > Thanks for the reply. I'm sending short strings as commands to my server > machine so the socket module seems to be doing the trick reliably. I'll try > to add Twisted to my arsenal though. > Cheers I've never used Twisted, so I can't say how good

Re: First python program, syntax error in while loop

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 6:11 AM, Terry Jan Reedy wrote: > On 5/6/2013 11:31 AM, Roy Smith wrote: >> >> In article , >> Chris Angelico wrote: >>> If I ever have even the slightest doubt, I just go ahead and type >>> " operator precedence" into

Re: python backup script

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 5:01 AM, MMZ wrote: > username = config.get('client', 'mmz') > password = config.get('client', 'pass1') > hostname = config.get('client', 'localhost') Are 'mmz', 'pass1', and 'localhost' the actual values you want for username, password, and hostname? If so, don't pass them

Re: python backup script

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 8:40 AM, MMZ wrote: > Thanks Chris. you are right. > So I used them directly and removed configParser. The new error is: > > Traceback (most recent call last): > File "./bbk.py", line 11, in ? > for database in os.popen(database_list_command).readlines(): > NameError:

Re: Red Black Tree implementation?

2013-05-06 Thread Chris Angelico
On Tue, May 7, 2013 at 10:55 AM, duncan smith wrote: > Here's the text I usually prepend. > > > ##Copyright (c) 2013 duncan g. smith > ## > ##Permission is hereby granted, free of charge, to any person obtaining a > ##copy of this software and associated documentation files (the "Software"), > ##t

Re: First python program, syntax error in while loop

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 4:10 PM, Mark Lawrence wrote: > On 07/05/2013 01:17, alex23 wrote: >> >> On May 6, 10:37 pm, Mark Lawrence wrote: >>> >>> One of these days I'll work out why some people insist on using >>> superfluous parentheses in Python code. Could it be that they enjoy >>> exercising

Re: use python to split a video file into a set of parts

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 9:15 PM, iMath wrote: > I use the following python code to split a FLV video file into a set of parts > ,when finished ,only the first part video can be played ,the other parts are > corrupted.I wonder why and Is there some correct ways to split video files Most complex f

Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 11:22 PM, jmfauth wrote: > There are plenty of good reasons to use Python. There are > also plenty of good reasons to not use (or now to drop) > Python and to realize that if you wish to process text > seriously, you are better served by using "corporate > products" or tools

Re: First python program, syntax error in while loop

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 10:44 PM, Ombongi Moraa Fe wrote: > My first language was Pascal. It was at a time in 2005 when computers were > finally becoming popular in Africa and our year was the first time a girls > school from our Province did a computer coursework for National Exams. (That > was su

Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread Chris Angelico
On Wed, May 8, 2013 at 12:57 AM, MRAB wrote: > Also, please read this: > > http://wiki.python.org/moin/GoogleGroupsPython > > because gmail insists on adding extra linebreaks, which can be somewhat > annoying. Accuracy correction: It's nothing to do with gmail, which is what I use (via python-lis

Re: Making safe file names

2013-05-07 Thread Chris Angelico
On Wed, May 8, 2013 at 8:18 AM, Fábio Santos wrote: > I suggest Base64. b64encode > (http://docs.python.org/2/library/base64.html#base64.b64encode) and > b64decode take an argument which allows you to eliminate the pesky "/" > character. It's reversible and simple. But it doesn't look anything li

Re: cello library

2013-05-08 Thread Chris Angelico
On Wed, May 8, 2013 at 7:39 PM, Mark Lawrence wrote: > Hi folks, > > I thought some of you might find this interesting [link redacted] If this is a legit post, can you please elaborate on just _why_ we would find it interesting? I'm leery of clicking random links like that without at least some i

Re: MySQL Database

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 4:52 AM, Kevin Holleran wrote: > Will using db_c to update the database mess up the loop that is cycling > through db_c.fetchall()? Nope; fetchall() returns a list, which you're then iterating over. Nothing the database does can disrupt that. ChrisA -- http://mail.python.

Re: cello library

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 7:06 AM, Terry Jan Reedy wrote: > Legitimate request, like some I have made of others. Since I trust Mark: It's actually nothing to do with trusting Mark. I've often seen posts from addresses of people I trust, but with links that I definitely would not want to click... and

Re: Style question -- plural of class name?

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 6:20 AM, Roy Smith wrote: > "A list of FooEntry's" Only if you put another apostrophe in: "A list of 'FooEntry's" But the delimited style is almost never of use. I'd go for this only if there were some sort of automated markup being applied - if the word FooEntry were tur

Re: Making safe file names

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 10:16 AM, Roy Smith wrote: > Pro-tip, guys. If you want to form a band, and expect people to be able > to find your stuff in a search engine some day, don't play cute with > your name. It's the modern equivalent of names like Catherine Withekay. ChrisA -- http://mail.pyt

Re: object.enable() anti-pattern

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 3:37 PM, Steven D'Aprano wrote: > I can see use-cases for separating "make it go" from initialisation. It > all depends on what you might want to do to the object before making it > go. If the answer is "Nothing", then there is no reason not to have the > constructor make it

Re: Append to python List

2013-05-09 Thread Chris Angelico
On Thu, May 9, 2013 at 4:36 PM, RAHUL RAJ wrote: > output=[x for x in sample2 if x not in output] > > output=[] > for x in sample2: > if x not in output: > output.append(x) The first one constructs a list, then points the name 'output' at it. The second one builds up a list, with 'output'

Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:35 AM, chandan kumar wrote: > > Hi all, > I'm new to python and facing issue using serial in python.I'm facing the > below error > > ser.write(port,command) > NameError: global name 'ser' is not defined > > Please find the attached script and let me know whats wrong

Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:35 AM, chandan kumar wrote: > Please find the attached script and let me know whats wrong in my script > and also how can i read data from serial port for the same script. Don't do this: except serial.serialutil.SerialException: print "Exception" se

Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 4:59 AM, Roy Smith wrote: > It's not hard to imagine a > file class which could be used like: > > f = file("/path/to/my/file") > f.delete() > > That would be a totally different model from the current python file > object. And then there would be plenty of things you might

Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 8:30 AM, Ian Kelly wrote: > On Thu, May 9, 2013 at 3:51 PM, Mark Janssen > wrote: >> the community stays fractured. > > The open source community seems pretty healthy to me. What is the > basis of your claim that it is "fractured"? The carpentry community is fractured.

Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 9:58 AM, alex23 wrote: > On 10 May, 07:51, Mark Janssen wrote: >> Languages can reach for an optimal design (within a >> constant margin of leeway). Language "expressivity" can be measured. > > I'm sure that's great. I, however, have a major project going live in > a few

Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 12:30 PM, Steven D'Aprano wrote: > I must admit I am astonished at how controversial the opinion "if your > object is useless until you call 'start', you should automatically call > 'start' when the object is created" has turned out to be. I share your astonishment. This i

Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:19 PM, Mark Janssen wrote: >> I think where things went pear shaped is when you made the statement: >> There is no sensible use-case for creating a file OBJECT unless it initially wraps an open file pointer. >> >> That's a pretty absolute point of view. Life is

Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:08 PM, Mark Janssen wrote: > On Thu, May 9, 2013 at 4:58 PM, alex23 wrote: >> On 10 May, 07:51, Mark Janssen wrote: >>> You see Ian, while you and the other millions of coding practitioners >>> have (mal)adapted to a suboptimal coding environment where "hey >>> there's

Re: Message passing syntax for objects | OOPv2

2013-05-10 Thread Chris Angelico
On Fri, May 10, 2013 at 2:55 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> The first hard disk I ever worked with stored 20MB in the space of a >> 5.25" slot (plus its associated ISA controller card). > > Heh. The first hard disk I ever wo

Re: object.enable() anti-pattern

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 12:37 AM, Roy Smith wrote: > I suppose, if I had a class like this, I would write a factory function > which called the constructor and post-construction initializer. And > then I would make the constructor protected. That sounds like a reasonable plan, with the possible

Re: object.enable() anti-pattern

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 12:54 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Sat, May 11, 2013 at 12:37 AM, Roy Smith wrote: >> > I suppose, if I had a class like this, I would write a factory function >> > which called the constructor

Re: Unicode humor

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 1:06 AM, jmfauth wrote: > On 8 mai, 15:19, Roy Smith wrote: >> Apropos to any of the myriad unicode threads that have been going on >> recently: >> >> http://xkcd.com/1209/ > > -- > > > This reflects a lack of understanding of Unicode. By the skywriter, or by the two

Re: Unicode humor

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder wrote: > On 5/10/2013 11:06 AM, jmfauth wrote: >> >> On 8 mai, 15:19, Roy Smith wrote: >>> >>> Apropos to any of the myriad unicode threads that have been going on >>> recently: >>> >>> http://xkcd.com/1209/ >> >> -- >> >> >> This reflects a lac

Re: object.enable() anti-pattern

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 1:21 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: >> >> Agreed, in generality. But what is actually gained by hiding data from >> yourself? > > You're not hiding it from yourself. You're hiding it from the other

Re: object.enable() anti-pattern

2013-05-10 Thread Chris Angelico
On Sat, May 11, 2013 at 1:44 AM, Serhiy Storchaka wrote: > 10.05.13 15:19, Robert Kern написав(ла): > >> I'd be curious to see in-the-wild instances of the anti-pattern that you >> are talking about, then. > > > Many (if not most) GUI frameworks use this pattern. > > button = Button("text") >

Re: Unicode humor

2013-05-11 Thread Chris Angelico
On Sat, May 11, 2013 at 2:07 AM, rusi wrote: > On May 10, 8:32 pm, Chris Angelico wrote: >> On Sat, May 11, 2013 at 1:24 AM, Ned Batchelder >> wrote: >> > On 5/10/2013 11:06 AM, jmfauth wrote: >> >> >> On 8 mai, 15:19, Roy Smith wrote: >> >

Re: Making safe file names

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 1:08 PM, Steven D'Aprano wrote: > I suspect that the only way to be completely ungoogleable would be to > name yourself something common, not something obscure. Say, if you called > yourself "Hard Rock Band", and did hard rock. But then, googling for > "Heavy Metal" alone br

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen wrote: > 8 Dihedral writes: > >> This is just the handy style for a non-critical loop. >> In a critical loop, the number of the total operation counts >> does matter in the execution speed. > > Do you use speed often? Dihedral is a bot. Quite

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Fri, May 10, 2013 at 3:33 AM, Ian Kelly wrote: > All this irrelevant nonsense > about Turing machines and lambda calculus that you've injected into > the conversation though just reminds me of the "Einstein was wrong" > cranks. http://xkcd.com/1206/ ChrisA -- http://mail.python.org/mailman/l

Re: Unicode humor

2013-05-11 Thread Chris Angelico
On Sat, May 11, 2013 at 10:40 PM, Mark Lawrence wrote: > This simply shows bias to the English speaking world, as does Python > unicode, at least in 3.3+. I wouldn't mind betting that other languages > can't cope, e.g. can 3.3+ manage the top secret joke that's so deadly even > the Germans die la

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:47 AM, Anssi Saari wrote: > Chris Angelico writes: > >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen >> wrote: >>> 8 Dihedral writes: >>> >>>> This is just the handy style for a non-critical loop. >>>

Re: object.enable() anti-pattern

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:33 AM, André Malo wrote: > * Serhiy Storchaka wrote: > >> Another example is running a subprocess in Unix-like systems. >> >> fork() >> open/close file descriptors, set limits, etc >> exec*() > > For running a subprocess, only fork() is needed. For starting

Re: object.enable() anti-pattern

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 5:55 AM, Robert Kern wrote: >> Another example of temporal coupling is json_decode in PHP: you must >> follow it by a call to json_last_error, otherwise you have no way of >> telling whether the json_decode function succeeded or not. >> >> http://php.net/manual/en/function.

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber wrote: > On Fri, 10 May 2013 14:33:52 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> I don't answer to them. I also believe in a path of endless >> exponential growth. Ch

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 10:50 AM, Gregory Ewing wrote: > Dennis Lee Bieber wrote: >>> >>> I also believe in a path of endless >>> exponential growth. Challenge: Create more information than can be >>> stored in one teaspoon of matter. Go ahead. Try! > > > If that's your argument, then you don't re

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 11:02 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber >> wrote: > > >>>The coordinates of each particle storing the information in that >>> teaspoon of matter.

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 12:29 PM, 8 Dihedral wrote: > Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道: >> Most humans would get defensive, or at >> least protest, if treated as bots; Dihedral never has, despite being >> referred to in this way a number of times. >>

Re: Python for philosophers

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 2:22 PM, rusi wrote: > On May 12, 3:16 am, alex23 wrote: >> On 12 May, 06:10, Mark Janssen wrote: >> >> > Wow. You must be from another planet. Find Socrates if you wish to >> > know these things. He's from there also. >> >> Now now, there's no need for a turf war, the

Old version docs don't link to current version

2013-05-12 Thread Chris Angelico
Not sure if this is an oversight or something deliberate... could be either. >From http://docs.python.org/3.0/library/http.server.html there's no link to the current docs, even though from http://docs.python.org/3/library/http.server.html it's possible to switch to 3.2 and then back to 3.3 (or to

Re: Python for philosophers

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 12:17 AM, Citizen Kant wrote: > Maybe It'd be good if I explain myself a bit more. What I'm trying here is > to grasp Python from the game's abstraction point of view, as if it were, > for example, chess. Maybe you're going for something a little too complicated. Let's boi

Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 1:59 AM, Chris “Kwpolska” Warrick wrote: > On Sun, May 12, 2013 at 12:20 AM, Jens Thoms Toerring > wrote: >> PS: If I may ask you a favor: consider refraining from using Google's >> completely broken interface to newsgroups - your post consists >> of nearly 200 li

Re: Python for philosophers

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 4:13 AM, llanitedave wrote: > On Sunday, May 12, 2013 7:51:28 AM UTC-7, Chris Angelico wrote: >> On Mon, May 13, 2013 at 12:17 AM, Citizen Kant wrote: >> >> > Maybe It'd be good if I explain myself a bit more. What I'm trying here i

Re: Old version docs don't link to current version

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 5:32 AM, Terry Jan Reedy wrote: > On 5/12/2013 10:12 AM, Chris Angelico wrote: >> >> Was this intentional, along the lines of not touching the old and >> unsupported docs? > > Cross referencing was added while 3.2 docs were still subject

Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 7:56 AM, Jens Thoms Toerring wrote: > Chris “Kwpolska” Warrick wrote: >> Gmail automatically hides long quotes. This is helpful in situations >> like this one. More mail software should implement that >> functionality. Seriously: once you go Gmail, you never go back. >

Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 8:58 AM, Jens Thoms Toerring wrote: > Chris Angelico wrote: >> On Mon, May 13, 2013 at 7:56 AM, Jens Thoms Toerring >> wrote: >> > Chris “Kwpolska” Warrick wrote: >> >> Gmail automatically hides long quotes. This is helpful in s

Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 9:47 AM, Dennis Lee Bieber wrote: > On Mon, 13 May 2013 08:18:05 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> No, Chris (not me, the other Chris... *an*other Chris okay, one of >> the chorus of Chri

Re: object.enable() anti-pattern

2013-05-13 Thread Chris Angelico
On Mon, May 13, 2013 at 4:32 PM, Fábio Santos wrote: > > On 13 May 2013 00:22, "Greg Ewing" wrote: >> The same argument can be applied to: >> >>foo = Foo() >>foo.do_something() >>foo.enable() # should have done this first >> >> You're passing an invalid input to Foo.do_something, >> n

Re: Python for philosophers

2013-05-13 Thread Chris Angelico
On Tue, May 14, 2013 at 12:53 AM, rusi wrote: > int fact(int n, int acc) > { > return !n? acc : fact(n-1,acc*n); > } > - > When I run these, the C happily keeps giving answers until a million > > However examined closely we find that though the C is giving answers

Re: Python's sad, unimaginative Enum

2013-05-13 Thread Chris Angelico
On Mon, May 13, 2013 at 8:17 PM, Steven D'Aprano wrote: > Let's look at his major criticisms: > > 1) values aren't automatically generated. > > True. So what? That is the *least* important part of enums. I stopped following the -ideas threads about enums, but IIRC autogeneration of values was in

Re: [Off topic] Software epigrams

2013-05-13 Thread Chris Angelico
On Mon, May 13, 2013 at 7:20 PM, Steven D'Aprano wrote: > My, it's been a long time since I've seen these: > > http://pu.inf.uni-tuebingen.de/users/klaeren/epigrams.html > > They pre-date the Zen of Python by at least a decade, and quite frankly I > think many of them miss the mark. But whether yo

Re: [Off topic] Software epigrams

2013-05-13 Thread Chris Angelico
On Tue, May 14, 2013 at 4:02 AM, Skip Montanaro wrote: >> 8. A programming language is low level when its programs require >> attention to the irrelevant. >> >> So much a matter of debate. Indentation is irrelevant, why should >> Python programs pay attention to it? Block delimiters are irrelevant

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-13 Thread Chris Angelico
On Tue, May 14, 2013 at 4:08 AM, Ned Batchelder wrote: > > On 5/13/2013 1:26 PM, Fábio Santos wrote: > > > On 13 May 2013 11:04, "Alister" wrote: >> this looks to me like an issue with operator precidence >> >> you code is evaluating as (Not x) == y >> rather than not (x == y) > > I can say for s

Re: [Off topic] Software epigrams

2013-05-13 Thread Chris Angelico
On Tue, May 14, 2013 at 1:08 PM, Dan Sommers wrote: > And if I've designed my program the right way, what's relevant in one > place (package, module, function, line of code) is different from what's > relevant in another. Absolutely. Layered systems FTW! Nothing matters but your current layer and

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:22 AM, Dave Angel wrote: > On 05/13/2013 06:53 PM, Mark Lawrence wrote: >> I much prefer the alternative <> for != but some silly people insisted >> that this be removed from Python3. Just how stupid can you get? >> > > So which special methods should the <> operator cal

Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:40 AM, Fábio Santos wrote: > Well I am thus defying the law and order of this world by publishing > it on the internets! > > --- > > And here it is: > http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html class Text(unicode, Enum): one = u'on

Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy wrote: > On 5/14/2013 3:52 AM, Chris Angelico wrote: >> >> On Tue, May 14, 2013 at 9:40 AM, Fábio Santos >> wrote: > >>> http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html >&

Re: Python for philosophers

2013-05-15 Thread Chris Angelico
On Tue, May 14, 2013 at 4:14 AM, rusi wrote: > It costs $10K for a car which goes at around 80 kmph > > Now if I want to move at 800 kmph I need to switch from car to plane > and that will cost me in millions > > And if I want to move at 8000 kmph I need to be in a rocket in outer > space. Cost pe

Re: Translation API in Python

2013-05-15 Thread Chris Angelico
On Thu, May 16, 2013 at 8:00 AM, Hala Gamal wrote: > I want to use A translator from Arabic to English and reverse in my > application which is written in pyhton, > Is there any open source Translator that can be used with python, > Or Any Suggestion? > Please Help, > Thanks In Advance :) I wou

Re: Fractal

2013-05-16 Thread Chris Angelico
On Thu, May 16, 2013 at 5:11 PM, Ulrich Eckhardt wrote: > Am 16.05.2013 02:00, schrieb alex23: > >> My favourite is this one: >> >> http://preshing.com/20110926/high-resolution-mandelbrot-in-obfuscated-python > > > Not only is this blog entry an interesting piece of art, there's other > interestin

Re: Fwd: Fwd: Fwd: Python for philosophers

2013-05-16 Thread Chris Angelico
On Thu, May 16, 2013 at 11:46 PM, rusi wrote: > IOW a programmer is one who quickly and easily comes to the nub/core/ > kernel/essence of a problem and as easily and adroitly shaves off the > irrelevant. +1. This is a fairly good description of a programmer's job. Of course, that's the theoretic

Re: [Off topic] Software epigrams

2013-05-16 Thread Chris Angelico
On Fri, May 17, 2013 at 12:23 AM, Neil Cerutti wrote: > On 2013-05-16, F?bio Santos wrote: >> And in Java we have factories, builders and builderfactories. >> What's so relevant about them? Java is high level, no? > > When I tried to pin down what an irrelevant detail in a computer > program coul

Re: Software epigrams

2013-05-16 Thread Chris Angelico
On Fri, May 17, 2013 at 1:06 AM, rusi wrote: > On May 16, 7:37 pm, Chris Angelico wrote: >> On Fri, May 17, 2013 at 12:23 AM, Neil Cerutti wrote: >> > When I tried to pin down what an irrelevant detail in a computer >> > program could be, I couldn't do

Re: spilt question

2013-05-16 Thread Chris Angelico
On Fri, May 17, 2013 at 1:00 AM, loial wrote: > I want to split a string so that I always return everything BEFORE the LAST > underscore > > HELLO_.lst # should return HELLO > HELLO_GOODBYE_.ls # should return HELLO_GOODBYE > > I have tried with rsplit but cannot get it t

Re: any cherypy powred sites I can check out?

2013-05-16 Thread Chris Angelico
On Fri, May 17, 2013 at 4:17 AM, wrote: > anyone? > -- > http://mail.python.org/mailman/listinfo/python-list You're firing off a bunch of minimal-content threads that ask other people to do work for you. I recommend you put a bit more thought into your posts, and show that you're willing to do a

Re: Two Dictionaries and a Sum!

2013-05-17 Thread Chris Angelico
On Sat, May 18, 2013 at 2:19 PM, Bradley Wright wrote: > Confusing subject for a confusing problem (to a novice like me of course!) > Thx for the help in advance folks > > I have (2) dictionaries: > > prices = { > "banana": 4, > "apple": 2, > "orange": 1.5, > "pear": 3 > } > > stoc

Re: How to write fast into a file in python?

2013-05-17 Thread Chris Angelico
On Sat, May 18, 2013 at 2:01 PM, Steven D'Aprano wrote: > Consider if x is an arbitrary object, and you call "%s" % x: > > py> "%s" % 23 # works > '23' > py> "%s" % [23, 42] # works > '[23, 42]' > > and so on for *almost* any object. But if x is a tuple, strange things > happen Which can be gua

Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sat, May 18, 2013 at 8:12 PM, Avnesh Shakya wrote: > avin@hp:~$ crontab -e > then type - > */2 * * * * python /home/avin/data/try.py > You may need to put an explicit path to your Python interpreter. Type: $ which python and put that into your crontab. ChrisA -- http://mail.python.org/mail

Re: How to write fast into a file in python?

2013-05-18 Thread Chris Angelico
On Sat, May 18, 2013 at 5:49 PM, Fábio Santos wrote: > Putting len(os.linesep)'s value into a local variable will make accessing it > quite a bit faster. But why would you want to do that? > > You mentioned "\n" translating to two lines, but this won't happen. Windows > will not mess with what you

Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 3:35 AM, woooee wrote: > The obvious question, do you have the shebang on the first line so the > OS knows it's to be run as a Python program? That won't make any difference; the cron job specifically stipulates the interpreter. It just needs to be done with a full path.

Re: python script is not running

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 4:43 AM, Vincent Vande Vyvre wrote: > Le 18/05/2013 19:59, Chris Angelico a écrit : > >> On Sun, May 19, 2013 at 3:35 AM, woooee wrote: >>> >>> The obvious question, do you have the shebang on the first line so the >>> OS k

Re: Python for philosophers

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 9:56 AM, 8 Dihedral wrote: > Hey, ChisA, are you delibrately to write a recursive version > to demonstrate the stack depth problem in Python? > > def fact(n): >ret=1 >if n>1: # integer checking is not used but can be added > for x in xrange(n): ret*=x >

Re: Please help with Threading

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 10:02 AM, Carlos Nepomuceno wrote: > I didn't know Python threads aren't preemptive. Seems to be something really > old considering the state of the art on parallel execution on multi-cores. > > What's the catch on making Python threads preemptive? Are there any ongoing >

Re: mutable ints: I think I have painted myself into a corner

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson wrote: > Before I toss this approach and retreat to my former "object" > technique, does anyone see a way forward to modify an int subclass > instance in place? (That doesn't break math, preferably; I don't > do arithmetic with these things but the

Re: any cherypy powred sites I can check out?

2013-05-18 Thread Chris Angelico
On Fri, May 17, 2013 at 10:09 AM, alex23 wrote: > On May 17, 10:00 am, visphatesj...@gmail.com wrote: >> is a cherrypy list accessible here on web thru google groups? > > Is an apology for your offensive response to Chris Angelico > forthcoming? In complete absence of all sembl

Re: any cherypy powred sites I can check out?

2013-05-18 Thread Chris Angelico
On Sat, May 18, 2013 at 3:15 AM, Mark Lawrence wrote: > On 17/05/2013 01:00, visphatesj...@gmail.com wrote: >> >> fuck straight off >> > > I assume you're the author of "How to win friends and influence people"? Not quite. He's the author of the social networking version, "How to win influence an

Re: How to write fast into a file in python?

2013-05-19 Thread Chris Angelico
On Sun, May 19, 2013 at 3:31 PM, Carlos Nepomuceno wrote: > Thanks Dan! I've never used CPython or PyPy. Will try them later. CPython is the "classic" interpreter, written in C. It's the one you'll get from the obvious download links on python.org. ChrisA -- http://mail.python.org/mailman/listi

Re: Harmonic distortion of a input signal

2013-05-19 Thread Chris Angelico
On Sun, May 19, 2013 at 8:52 PM, Anti Log wrote: > total distortion of a harmonics I selected this part of your post, right-clicked, and Chrome offered to do a Google search for those words. And, surprise surprise, the first hit is a page that appears to have the mathematics behind it. Now, I don

Re: Please help with Threading

2013-05-19 Thread Chris Angelico
On Mon, May 20, 2013 at 7:46 AM, Dennis Lee Bieber wrote: > On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: >> With interpreted code eg in CPython, it's easy to implement preemption >> in the interpreter. I don&#

Re: Question about ast.literal_eval

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 5:05 PM, Frank Millman wrote: > Hi all > > I am trying to emulate a SQL check constraint in Python. Quoting from the > PostgreSQL docs, "A check constraint is the most generic constraint type. It > allows you to specify that the value in a certain column must satisfy a > Bo

Re: Question about ast.literal_eval

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 5:50 PM, Frank Millman wrote: > On 20/05/2013 09:34, Carlos Nepomuceno wrote: >> Why don't you use eval()? >> > > Because users can create their own columns, with their own constraints. > Therefore the string is user-modifiable, so it cannot be trusted. Plenty of reason ri

Re: Question about ast.literal_eval

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 5:55 PM, Carlos Nepomuceno wrote: > I understand your motivation but I don't know what protection > ast.literal_eval() is offering that eval() doesn't. eval will *execute code*, while literal_eval will not. That's the protection. With ast.literal_eval, all that can happen

Re: Please help with Threading

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 6:35 PM, Cameron Simpson wrote: > _lock = Lock() > > def lprint(*a, **kw): > global _lock > with _lock: > print(*a, **kw) > > and use lprint() everywhere? Fun little hack: def print(*args,print=print,lock=Lock(),**kwargs): with lock: print(*args,**

Re: Please help with Threading

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 7:54 PM, Cameron Simpson wrote: > On 20May2013 19:09, Chris Angelico wrote: > | On Mon, May 20, 2013 at 6:35 PM, Cameron Simpson wrote: > | > _lock = Lock() > | > > | > def lprint(*a, **kw): > | > global _lock > | > wi

Re: Please help with Threading

2013-05-20 Thread Chris Angelico
=On Mon, May 20, 2013 at 8:46 PM, Ned Batchelder wrote: > On 5/20/2013 6:09 AM, Chris Angelico wrote: >> >> Referencing a function's own name in a default has to have one of >> these interpretations: >> >> 1) It's a self-reference, which can be used to

Re: Question about ast.literal_eval

2013-05-20 Thread Chris Angelico
On Mon, May 20, 2013 at 11:26 PM, Frank Millman wrote: > 0 - for the first entry in the list, the word 'check' (a placeholder - it is > discarded at evaluation time), for any subsequent entries the word 'and' or > 'or'. > > 1 - left bracket - either '(' or ''. > > 5 - right bracket - either ')' or

Re: Question about ast.literal_eval

2013-05-20 Thread Chris Angelico
On Tue, May 21, 2013 at 2:12 AM, Steven D'Aprano wrote: > Personally, I would strongly suggest writing your own mini- > evaluator that walks the list and evaluates it by hand. It isn't as > convenient as just calling eval, but *definitely* safer. Probably faster, too, for what it's worth - eval i

Re: Please help with Threading

2013-05-20 Thread Chris Angelico
On Tue, May 21, 2013 at 11:44 AM, 8 Dihedral wrote: > OK, if the python interpreter has a global hiden print out > buffer of ,say, 2to 16 K bytes, and all string print functions > just construct the output string from the format to this string > in an efficient low level way, then the next qu

Re: Question about ast.literal_eval

2013-05-21 Thread Chris Angelico
On Tue, May 21, 2013 at 4:46 PM, Frank Millman wrote: > You may be right, Chris, but I don't think my approach is all that bad. Frankly, I'm not altogether convinced that our approach is right either :) But like the Oracle in the Matrix, I'm not here to push you to one decision or another so much

Re: How to run a python script twice randomly in a day?

2013-05-21 Thread Chris Angelico
On Tue, May 21, 2013 at 11:12 AM, Cameron Simpson wrote: > Ok, good. Some minor remarks: > > Personally, I always use: > > #!/bin/sh > > instead of requiring bash. All UNIX systems have sh, bash is only > common. And even when present, it may not be in /bin. /bin/sh is > always there, and unless

Re: please help

2013-05-21 Thread Chris Angelico
On Tue, May 21, 2013 at 6:38 PM, wrote: > WAP in python to accept a list of words on STDIN and searches for a line > containing all five vowels(a,e,i,o,u) Homework. Have a shot at it yourself, post your code, show that you can put in some effort. Otherwise we won't see much reason to put in ef

Re: sympy.nsimplify

2013-05-21 Thread Chris Angelico
On Tue, May 21, 2013 at 6:26 PM, Steven D'Aprano wrote: > For maths nerds like me, this is too cool for words: > > http://www.johndcook.com/blog/2013/04/30/recognizing-numbers/ It is indeed, very cool. I think I need to conjure an excuse to use this someplace. ChrisA -- http://mail.python.org/m

  1   2   3   4   5   6   7   8   9   10   >