Re: Generator vs functools.partial?

2012-06-21 Thread J. Cliff Dyer
On Thu, 2012-06-21 at 21:25 +1000, John O'Hagan wrote: > Sometimes a function gets called repeatedly with the same expensive argument: > > def some_func(arg, i): > (do_something with arg and i) > > same_old_arg = big_calculation() > for i in lots_of_items: > some_func(same_old_arg, i) >

List comprehension/genexp inconsistency.

2012-03-20 Thread J. Cliff Dyer
One of my coworkers just stumbled across an interesting issue. I'm hoping someone here can explain why it's happening. When trying to create a class with a dual-loop generator expression in a class definition, there is a strange scoping issue where the inner variable is not found, (but the outer

Re: List comprehension/genexp inconsistency.

2012-03-21 Thread J. Cliff Dyer
Binding" http://www.python.org/dev/peps/pep-0289/#early-binding-versus-late-binding Cheers, Cliff On Tue, 2012-03-20 at 16:50 -0600, Ian Kelly wrote: > On Tue, Mar 20, 2012 at 3:16 PM, Dennis Lee Bieber > wrote: > > On Tue, 20 Mar 2012 16:23:22 -0400,

Re: Best way to disconnect from ldap?

2012-03-21 Thread J. Cliff Dyer
Write a context manager. Then you just do with MyLDAPWrapper() as ldap ldap.this() ldap.that() and when you leave the scope of the with statement, your ldap __exit__ method will get called regardless of how you left. Cheers, Cliff On Wed, 2012-03-21 at 19:30 +, John Gordon wrote:

Re: Python classes: Simplify?

2012-03-22 Thread J. Cliff Dyer
The issue of explicitly naming a "self" parameter has been discussed in depth on a number of occasions. I recommend a google search for "python implicit self" for some of the reasons why it exists. Here's what Guido has to say about it: http://neopythonic.blogspot.com/2008/10/why-explicit-self-h

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

2012-03-26 Thread J. Cliff Dyer
As others have pointed out, the output is the same, because the result of converting an integer to a string is the string of that integer. However, other numeric literals might not do what you want, due to the fact that they are converted to an internal numeric representation, then converted back t

Re: help needed to understand an error message.

2012-03-30 Thread J. Cliff Dyer
So the problem is that python doesn't know what you're trying to do. It doesn't know that you meant to say "print." When the parser is looking at the word Print, it assumes you are referencing an object named Print, which is completely legal. It's only once you've created the next token, a strin

Re: I look for a package to make some simple console "form"

2012-04-02 Thread J. Cliff Dyer
You might look into formencode. It basically takes the philosophy that a form is nothing more and nothing less than an interface between user input and python data. It doesn't make assumptions about how you present the form to the user. It just handles validation and conversion of that data into

Re: Interprocess comunication

2012-06-07 Thread J. Cliff Dyer
On Thu, 2012-06-07 at 16:04 +, Julio Sergio wrote: > Up to this point it worked as expected. However, when I tryied with the > methods > that write and read several lines, apparently the process got stalled: > > ->>> fi.writelines(["uno\n","dos\n","tres\n"]) > ->>> fi.flush() > ->>> s = fo.

Re: Interprocess comunication

2012-06-07 Thread J. Cliff Dyer
It is for reading all the lines from a complete file. If the file is still being written to, it doesn't have an end yet. File objects do many things besides RPC. Also, there are instances where all you want to do is block until the file is done, and then get all the content. readlines will do th

Re: Academic citation of Python

2012-06-16 Thread J. Cliff Dyer
That's a rather vague question. What do you want to cite about python? If you're just mentioning python, that shouldn't warrant a citation, though a parenthetical note linking to python.org might be useful. The standard documentation should be acceptable, or possibly a link to the source code at

Re: How to optimise this code?

2007-08-21 Thread J. Cliff Dyer
David N Montgomery wrote: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.testCase5() > if tc == 6:self.testCase6

Re: for statement on empty iterable

2007-08-22 Thread J. Cliff Dyer
Neil Cerutti wrote: On 2007-08-22, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: While it is desireable to not only write working, but also aesthetically pleasing code, as a beginner you shouldn't worry too much. The sense of aesthetics develops with time. Important is to try and grasp the idio

Re: creating a tar file with python

2007-08-24 Thread J. Cliff Dyer
Brian McCann wrote: Hi, I'm trying to create a tar file of the contents of the current directory right now there is only one file "text.xml" in the current dir, I'm using"." current dir as source but that gives syntax error any help would be greatly appreciated --Brian #!/usr/bin/pyth

Re: Using Regular Expresions to change .htm to .php in files

2007-08-24 Thread J. Cliff Dyer
Tim Williams wrote: On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi, I have a bunch of files that have changed from standard htm files to php files but all the links inside the site are now broken because they point to the .htm files while they are now .php files. Does anyone h

Re: Using Regular Expresions to change .htm to .php in files

2007-08-24 Thread J. Cliff Dyer
t's a really big site and about 70-80% of the links are internal so we'll save time this way. There's probably a way to analyse if a link is internal or external, but I needed something fast. But still, I would be interested about knowing how to do such a thing for the future. On 8/24/07,

Re: How to replace a method in an instance.

2007-08-24 Thread J. Cliff Dyer
Steven W. Orr wrote: > On Friday, Aug 24th 2007 at 12:26 -0400, quoth Steven W. Orr: > > =>On Friday, Aug 24th 2007 at 09:12 -0700, quoth [EMAIL PROTECTED]: > => > =>=>On Aug 24, 11:02 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > =>=>> In the program below, I want this instance to end up callin

Re: Biased random?

2007-08-27 Thread J. Cliff Dyer
I don't know if this is pythonic or not, but try something like this: from math import log from random import randint def: skewedrandom(n): int(log(randrange(1,n), 2)) Play with your log to get the range you want Cheers, Cliff Grant Edwards wrote: On 2007-08-27, Jun-geun Park <[EMAIL PROTE

Re: strings (dollar.cents) into floats

2007-08-30 Thread J. Cliff Dyer
Gary Herron wrote: luca bertini wrote: Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: "numb = float(my_line) ValueError: empty string for float()" " here's the code import sys

Re: why should I learn python

2007-09-06 Thread J. Cliff Dyer
Torsten Bronger wrote: Hallöchen! Tom Brown writes: [...] Python has been by far the easiest to develop in. Some people might say it is not "real programming" because it is so easy. I can't believe this. Have you really heard such a statement? Tschö, Torsten. The catch-phrase s

Re: Modul (%) in python not like in C?

2007-09-09 Thread J. Cliff Dyer
Dotan Cohen wrote: > FIrst of all, how is the % symbol (as in 70%6=4) called in English? > > Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or > the other in error? Is this a known gotcha? I tried to google the > subject however one cannot google the symbol %. Thanks in advance.

Re: Python syntax wart

2007-09-10 Thread J. Cliff Dyer
J. Cliff Dyer wrote: Lawrence D'Oliveiro wrote: In message <[EMAIL PROTECTED]>, Bjoern Schliessmann wrote: What's wrong with this: for Link in GetEachRecord( Then you're no longer showing the syntax structure in two dimensions. If somebody handed me a

Re: question on python syntax

2007-09-10 Thread J. Cliff Dyer
Andrew Robert wrote: > a.m. wrote: >> If I type this in shell >> >> $ ./yourfile.py 12:34 PM & >> >> What does '$', '.', '/' and '& means in this succession? Note: >> 12:34 PM is a argument to the yourfile.py. >> > > This not python syntax but Unix shell. > > $ = shell prompt ./

Re: printing list containing unicode string

2007-09-10 Thread J. Cliff Dyer
Xah Lee wrote: > This post is about some notes and corrections to a online article > regarding unicod and python. > > -- > > by happenstance i was reading: > > Unicode HOWTO > http://www.amk.ca/python/howto/unicode > > Here's some problems i see: > > ・ No conspicuous authorship. (howeve

Re: Enum class with ToString functionality

2007-09-10 Thread J. Cliff Dyer
TheFlyingDutchman wrote: > On Sep 10, 7:12 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: >> TheFlyingDutchman <[EMAIL PROTECTED]> writes: http://cheeseshop.python.org/pypi/enum/> >> (Please preserve attribution lines so it's clear who wrote what.) >> >> >>> Looking at the documentation it look

Re: Modul (%) in python not like in C?

2007-09-11 Thread J. Cliff Dyer
Bryan Olson wrote: > Scott David Daniels wrote: > >> C, which was designed as a "high level assembly language," does not >> tightly define the results of / and % for negative numbers. Instead >> it defines the result for positive over positive, and constrains the >> result for the others. >>

Re: Enum class with ToString functionality

2007-09-11 Thread J. Cliff Dyer
Zara wrote: > On Mon, 10 Sep 2007 02:28:57 -0700, [EMAIL PROTECTED] wrote: > > >> Hi, >> >> I have the following class - >> >> class TestOutcomes: >>PASSED = 0 >>FAILED = 1 >>ABORTED = 2 >> >> plus the following code - >> >> testResult = TestOutcomes.PASSED >> >> testResultAsString >

Re: function to do dynamic import?

2007-09-11 Thread J. Cliff Dyer
bambam wrote: > import works in the main section of the module, but does > not work as I hoped when run inside a function. > > That is, the modules import correctly, but are not visible to > the enclosing (global) scope. > > Questions: > (1) Where can I read an explanation of this? > (2) Is there a

Re: Python statements not forcing whitespace is messy?

2007-09-15 Thread J. Cliff Dyer
buffi wrote: > Am I the only one that thinks that python statements should force > whitespace before and after them? > > Right now this is not enforced and for an example these statements are > valid > > print"hello" > "foo"if"bar"else"foobar" > for(x,y)in[(1,2),(3,4)]:print(x,y) > [(y)for(x,y)in[(

Re: string questions

2007-09-15 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: > But please don't use the functions in `string` that are also available as > methods on strings. Those functions are deprecated. > > Meaning (for newbie clarification): instead of string.upper(s2), just do s2.upper(). For more detail, see the docs. -- http

Re: generate list of partially accumulated values

2007-09-16 Thread J. Cliff Dyer
ZeD wrote: > cesco wrote: > > >> The list is composed of objects: >> l = [obj1, obj2, obj3, obj4] >> and I need to call a method (say method1) on each object as follow: >> l1 = [obj1.method1(obj2), obj2.method1(obj3), obj3.method1(obj4), >> obj4] >> > > to me it sounds a bit different from

SVG to raster conversion.

2007-09-16 Thread J. Cliff Dyer
Does anybody know a good solution (preferably in python) for rasterizing SVG or other vector graphics. I'm thinking something like vector_image = SVGFile(path_to_image) raster_image = vector_image.rasterize(format, (width, height), dpi) raster_image.write(out_file) Thanks for any pointers you mi

Re: SVG to raster conversion.

2007-09-16 Thread J. Cliff Dyer
Stefan Behnel wrote: > J. Cliff Dyer wrote: > >> Does anybody know a good solution (preferably in python) for rasterizing >> SVG or other vector graphics. >> >> I'm thinking something like >> >> vector_image = SVGFile(path_to_image) >>

Re: Python "with"

2007-09-16 Thread J. Cliff Dyer
Ivan Voras wrote: > Hi, > > I'm looking for a construct that's similar to (Turbo) Pascal's "with" > statement. I read about the Python's new "with" statement, but I was > dissapointed to learn that it does something different (I still don't > see how it's better than try..except..finally, but that'

Re: Try this

2007-09-16 Thread J. Cliff Dyer
[EMAIL PROTECTED] wrote: > The very presence of an algorithm to detect encoding is a bug. > Files with they .txt extension should always be treated as ANSI > even if they contain binary data. Notepad should never be > allowed to try to decide what the encoding is if the the open > dialog has the en

Re: Python "with"

2007-09-17 Thread J. Cliff Dyer
Ivan Voras wrote: > Laurent Pointal wrote: > >> The ugly part is the 'tmp' name, try to choose a name with a proper >> meaning about what it is really, and it become clean and readable: >> >> filerefs = some.big.structure.or.nested.object.with.file.references >> filerefs.encoding = "utf-8" >> filer

Re: adodb with mysql - connection string syntax for filepath

2007-09-17 Thread J. Cliff Dyer
Mridula Ramesh wrote: > Dear all, > > Hi. I am not very tech-savvy so please pardon me if this is a stupid > question: so far I have been googling for about 4 days to find help > for this, so now I am desperate! :) > > How do you use adodb with mysql to connect to a file that is on your > machine?

Re: UTF-8 characters in doctest

2007-09-20 Thread J. Cliff Dyer
John J. Lee wrote: > Peter Otten <[EMAIL PROTECTED]> writes: > [...] > >> def f(s): >> return (s,) >> > > Forgive me if this is a stupid question, but: What purpose does > function f serve? > > > John > Well, it has nothing to do with the unicode bit that came before it. It just ta

Re: UTF-8 characters in doctest

2007-09-20 Thread J. Cliff Dyer
J. Cliff Dyer wrote: > John J. Lee wrote: > >> Peter Otten <[EMAIL PROTECTED]> writes: >> [...] >> >> >>> def f(s): >>> return (s,) >>> >>> >> Forgive me if this is a stupid question, but: W

Re: RE Help

2007-09-21 Thread J. Cliff Dyer
Thomas Jollans wrote: > On Friday 21 September 2007, [EMAIL PROTECTED] wrote: > >> Not specific to Python, but it will be implemented in it... how do I >> compile a RE to catch everything between two know values? Here's what >> I've tried (but failed) to accomplish... the knowns here are START a

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread J. Cliff Dyer
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > > >> I think key may be to discuss names and name binding with your friend. How >> a name is not the object it self, like a variable is in other languages. >> For example show him how an object can have more than one na

Re: Question about quoting style.

2007-10-01 Thread J. Cliff Dyer
Bruno Desthuilliers wrote: > Steven W. Orr a écrit : > >> Python has a number of "quoting" 'options' to help """with >> times when""" one way may be more convenient than another. >> >> In the world of shell scripting, I use a technique that I call minimal >> quoting. It works like this: >> >> f

Re: Top Programming Languages of 2013

2007-10-07 Thread J. Cliff Dyer
James Matthews wrote: > What are these stats based on? > This survey here: http://app.sgizmo.com/reports/4762/6895/QJK8UD9C9371P37EOQ7V8OIC1RP39O/ Now how was this survey advertised? Who was asked to participate? Dunno. Clearly not MacFans, given the high number of 1 scores given to Objective

Re: pytz has so many timezones!

2007-10-08 Thread J. Cliff Dyer
On 10/8/07, *J. Clifford Dyer* <[EMAIL PROTECTED] > wrote: On Mon, Oct 08, 2007 at 01:13:24PM -0700, [EMAIL PROTECTED] wrote regarding Re: pytz has so many timezones!: > > On Oct 8, 1:03 pm, Carsten Haese < [EMAIL PROTECTED]

Re: pytz has so many timezones!

2007-10-09 Thread J. Cliff Dyer
Nicholas Bastin wrote: > > There is no central authority which defines global time zones. The > functional definition of a time zone is merely a geographical area of > the earth that has adopted the same local time rules. > In fact, even the authorities who do define time zones don't always have

Re: why doesn't have this list a "reply-to" ?

2007-10-16 Thread J. Cliff Dyer
Dick Crepeau wrote: > It seems to me the original question was how can I reply to a posted > message. > > I'm new here and see that while there are replies to several messages, > many times, like with this note, the issue is brought up as if it is new. > > I don't know how to do a reply, can some

Re: Failure to connect in SimpleXMLRPCServer/xmlrpclib

2007-10-22 Thread J. Cliff Dyer
iu2 wrote: > Hi all, > > I've copied the example of RPC usage from the Python's doc. > When the client and server were on the same PC ("localhost") (I use > Windows) > it worked ok. But putting the server on a different PC raised the > error: > > gaierror: (11001, 'getaddrinfo failed') > The error

Re: if..else stmt

2007-10-22 Thread J. Cliff Dyer
Your else statement is incorrectly indented. The interpreter treats it as part of the for-loop construct inside the if statement rather than as part of the if statement itself. See the recent thread about for-else constructs for more details. If your problem is not obvious yet, make sure you are

Re: if..else stmt

2007-10-22 Thread J. Cliff Dyer
bigden007 wrote: > Hi, > I have a if..else statement in my script. The statements all execute > fine, but the problem is , even if the IF part of the statement is > true, the else part executes as well. The verion of pythin i use 2.5 > Any help is appreciatiated. > > Regards > > Big Den. > > You

Re: Going past the float size limits?

2007-10-26 Thread J. Cliff Dyer
[EMAIL PROTECTED] wrote: > Hello all > It would be great if I could make a number that can go beyond current > size limitations. Is there any sort of external library that can have > infinitely huge numbers? Way way way way beyond say 5x10^350 or > whatever it is? > > I'm hitting that "inf" boundar

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Matimus wrote: >> - Traling characters at the end of a literal are already used (the L >> for long). >> > > The trailing L is going away in Python 3.0. For your consideration may > I suggest a '$' prefix. Though, I'm not sure I even support the idea > of a decimal literal, and I'm not even s

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Ben Finney wrote: > Matimus <[EMAIL PROTECTED]> writes: > > >> The trailing L [for 'long' literals] is going away in Python 3.0. >> > > Yes. On the other hand, we are gaining '0b' for binary literals, > to go along with '0o' for octal and '0x' for hexadecimal. > > So, the origin

Re: Alarming message when running Python code

2007-10-27 Thread J. Cliff Dyer
peter wrote: > I'm not sure if this query should be directed to comp.lang.python or > comp.os.linux.misc so I intend to post it to both with apologies if > it's inappropriate on either. > > I have a small python utility which I wrote myself and which crawls > through a directory comparing all possi

Re: while within while

2007-10-27 Thread J. Cliff Dyer
Shawn Minisall wrote: > K I've since fixed the UnboundLocalError: local variable 'ai' referenced > before assignment error, I forgot to include decision = (1, 2, 3) inside > " " for each number. > > You mean like decision = ("1", "2", "3") ? I don't think that would have caused the error you

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: > On Sat, 27 Oct 2007 13:28:02 -0500, Tim Chase wrote: > > Even clearer is not to allow octal literals :) Is there *any* use for them? >>> The mode argument to os.chmod. >>> >> You mean instead of >> >> import this >> os.chmod(fi

Re: tuples within tuples

2007-10-27 Thread J. Cliff Dyer
J. Clifford Dyer wrote: > On Fri, Oct 26, 2007 at 06:59:51AM -0700, [EMAIL PROTECTED] wrote regarding > Re: tuples within tuples: > >>> Resolve *what*? The problem isn't clear yet; at least to me. Above you >>> say what you get. What exactly do you want? Examples please. >>> >>> >> S

Re: Pari Python

2007-10-28 Thread J. Cliff Dyer
Anton Mellit wrote: > And I think (correct me if I am wrong) that the ^ operator (xor) is > used very very infrequently. And it is not difficult to replace all ^ > with say ^^. Oh God! *Please* don't start that conversation again. We had a thread about bitwise operators a few weeks back. Half t

Re: attaching someconfusing results in webbrowser.open on gnulinux

2007-11-01 Thread J. Cliff Dyer
krishnakant Mane wrote: > hello all, > I had mentioned previously that I can't open html files in python. > I have my username as krishna and there is a documents folder. > so when I give webbrowser.open("file:///home/krishna/documents/tut.html") > on python prompt I get true as return value but we

Re: A Python 3000 Question

2007-11-01 Thread J. Cliff Dyer
Steven D'Aprano wrote: > On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: > > >>> I hope you're not serious that $# would make a good operator. >>> >> If you happen to know where I borrowed it from, it would be pretty >> evident that I wasn't being serious. >> > > Ooh, now I'm c

Re: serving html from a python script in IE

2007-11-01 Thread J. Cliff Dyer
bluegray wrote: > I'm writing a script that outputs html. It works fine in Firefox, > however, IE wants to download the file instead of displaying the > output. I keep getting the file download dialog instead of the html > page. > > I am doing something like this: > > print 'Content-Type: text/html

Re: ValueError: invalid \x escape

2007-11-01 Thread J. Cliff Dyer
crybaby wrote: > I wrote a python code in linux text pad and copied to thumb drive and > try to ran the file by changing the path to windows: > > sys.path = sys.path + ['D:\Python24\Lib\site-packages\mycode] > > I get the following error: > > ValueError: invalid \x escape > > I am pretty sure this

Re: regular expressions

2007-11-07 Thread J. Cliff Dyer
Paul McGuire wrote: > On Nov 6, 11:07 am, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > >> On Tue, Nov 06, 2007 at 08:49:33AM -0800, [EMAIL PROTECTED] wrote regarding >> regular expressions: >> >> >> >> >>> hi i am looking for pattern in regular expreesion that replaces >>> anything star

Re: How about adding rational fraction to Python?

2008-02-25 Thread J. Cliff Dyer
On Mon, 2008-02-25 at 16:27 +, Grant Edwards wrote: > On 2008-02-25, Carl Banks <[EMAIL PROTECTED]> wrote: > > > In other words, 3/4 in Python rightly yields a float > > Unless you're in the camp that believes 3/4 should yield the > integer 0. ;) I'm in the camp that believes that 3/4 does i

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 04:29 -0800, Lie wrote: > > J Cliff Dyer: > > I'm in the camp that believes that 3/4 does indeed yield the integer > 0, > > but should be spelled 3//4 when that is the intention. > > That's creepy for people that are new to programming

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 10:08 -0500, D'Arcy J.M. Cain wrote: > On Tue, 26 Feb 2008 06:45:45 -0800 (PST) > Carl Banks <[EMAIL PROTECTED]> wrote: > > On Feb 26, 9:29 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > > > If 3/4 ever returned 0.75 in any language I would drop that language. > > > > Ha

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 13:51 -0500, D'Arcy J.M. Cain wrote: > On Tue, 26 Feb 2008 13:39:38 -0500 > "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > > >>> a = 2 * 2 > > >>> b = 20 * 20 > > >>> type(a) > > &

Re: How about adding rational fraction to Python?

2008-02-28 Thread J. Cliff Dyer
On Thu, 2008-02-28 at 11:22 -0500, D'Arcy J.M. Cain wrote: > Not obvious to you. You are using subjective perception as if it was > a > law of nature. If "obvious" was the criteria then I would argue that > the only proper result of integer division is (int, int). Give me the > result and the re

Skull Socks (was Re: Convention vs. fascism)

2009-01-16 Thread J. Cliff Dyer
On Fri, 2009-01-16 at 08:57 +, Steven D'Aprano wrote: > On Fri, 16 Jan 2009 10:03:28 +0200, Hendrik van Rooyen wrote: > > > Oh come on you lot - you are carrying on as if Diez were wearing his > > skull socks again - do me a favour and give him a break! > And... skull socks? Cool. Where can

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread J. Cliff Dyer
I dub it Schluehr's law. On Thu, 2009-01-22 at 21:39 -0800, Kay Schluehr wrote: > Whatever sufficiently sophisticated topic was the initially discussed > it ends all up in a request for removing reference counting and the > GIL. > > -- > http://mail.python.org/mailman/listinfo/python-list > --

Re: Newby: how to transform text into lines of text

2009-01-26 Thread J. Cliff Dyer
On Sun, 2009-01-25 at 18:23 -0800, John Machin wrote: > On Jan 26, 1:03 pm, "Gabriel Genellina" > wrote: > > En Sun, 25 Jan 2009 23:30:33 -0200, Tim Chase > > escribió: > > > > > > > > > Unfortunately, a raw rstrip() eats other whitespace that may be > > > important. I frequently get tab-de

Re: I'm a python addict !

2009-01-26 Thread J. Cliff Dyer
On Mon, 2009-01-26 at 14:43 -0800, J Kenneth King wrote: > Linuxguy123 writes: > > > I just started using python last week and I'm addicted. > > > > I hate Perl. I never did learn to use it with any competence. I has to > > be the most obfuscated, cryptic language I've ever seen. Making it >

Re: I'm a python addict !

2009-01-26 Thread J. Cliff Dyer
On Fri, 2009-01-23 at 20:25 -0800, Paul McGuire wrote: > Want to change the type/behavior of an object from class A to class > B? How about this: > > aobj = A() > aobj.__class__ = B > > Try *that* in as simple-looking C++ or Java! Wow. That looks very powerful and fun. But scary. An

Re: I'm a python addict !

2009-01-26 Thread J. Cliff Dyer
On Mon, 2009-01-26 at 09:52 -0800, Paul McGuire wrote: > On Jan 26, 10:54 am, "J. Cliff Dyer" wrote: > > On Fri, 2009-01-23 at 20:25 -0800, Paul McGuire wrote: > > > Want to change the type/behavior of an object from class A to class > > > B? H

Re: I'm a python addict !

2009-01-26 Thread J. Cliff Dyer
On Mon, 2009-01-26 at 12:37 -0800, Paul McGuire wrote: > On Jan 26, 2:06 pm, "J. Cliff Dyer" wrote: > > > > Thanks. That makes sense. But your example creates a new instance of > > the new class each time, rather than changing the class of a persistent > >

Re: is None vs. == None

2009-01-27 Thread J. Cliff Dyer
On Fri, 2009-01-23 at 19:31 -0500, Benjamin Kaplan wrote: > > > On Fri, Jan 23, 2009 at 7:28 PM, Gary Herron > wrote: > Steven D'Aprano wrote: > > On Fri, 23 Jan 2009 14:58:34 -0500, Gerald Britton wrote: > > > > > >> Hi -- Some time ago I ran across a co

Re: v = json.loads("{'test':'test'}")

2009-01-27 Thread J. Cliff Dyer
On Sun, 2009-01-25 at 14:28 -0800, gert wrote: > On Jan 25, 11:16 pm, Дамјан Георгиевски wrote: > > > raise ValueError(errmsg("Expecting property name", s, end)) > > >http://docs.python.org/library/json.html > > > What am I doing wrong ? > > > > try this > > v = json.loads('{"test":"test"}') > >

Re: English-like Python

2009-02-03 Thread J. Cliff Dyer
On Thu, 2009-01-22 at 09:07 -0700, Joe Strout wrote: > >> Beep > >> > >> Doesn't get much more readable and syntax-free than that. > > > > readable doesn't mean smallest amount of syntax possible sometimes > syntax > > increases the readability of a text as you would see if we for > example

Re: English-like Python

2009-02-03 Thread J. Cliff Dyer
On Tue, 2009-02-03 at 08:33 -0700, Joe Strout wrote: > J. Cliff Dyer wrote: > > > But what if your language allows functions to be used as first class > > objects? (Mine does :)) > > > > x = Beep > > > > Does that assign the name x to the Beep ob

Re: RedHat 4

2009-02-16 Thread J. Cliff Dyer
It *works* in RHEL 4, but it doesn't come as a package. RHEL4 ships with Python 2.3, and RHEL 5 only ships with Python 2.4, even though 2.5 had been out for god knows how long when it came out. Though I haven't tested it, I wouldn't recommend replacing the system's python binary with 2.5 if you d

Re: Pythonic way to determine if one char of many in a string

2009-02-16 Thread J. Cliff Dyer
On Mon, 2009-02-16 at 00:28 -0500, Nicolas Dandrimont wrote: > * [email protected] [2009-02-16 00:17:37 -0500]: > > > I need to test strings to determine if one of a list of chars is > > in the string. A simple example would be to test strings to > > determine if they have a vowel (aeiouAEIOU)

Re: wxPython and Croatian characters

2009-02-16 Thread J. Cliff Dyer
On Mon, 2009-02-16 at 20:06 +0100, Diez B. Roggisch wrote: > [email protected] schrieb: > > Hello, > > > > I have problem with configuring my wxPython script to work with > > Croatian characters like: đ,š,ž,č,ć. > > Here is my simple script without wxPython (this script works): > > > >

Re: Is there something easier than ORM?

2009-02-17 Thread J. Cliff Dyer
On Tue, 2009-02-17 at 06:15 -0800, 一首诗 wrote: > Thanks for your reply. > > With sqlalchemy, an mapped must living in a session, you have no way > to disconnect it with its session. > > For example : > > #- > user = session.query(User).first() > session.expung

Re: pydoc enforcement.

2008-12-01 Thread J. Cliff Dyer
On Sun, 2008-11-30 at 16:27 -0800, [EMAIL PROTECTED] wrote: > I've been thinking about implementing (although no idea yet *HOW*) the > following features/extension for the python compile stage and would be > interested in any thoughts/comments/flames etc. > > Basically I'm interested adding a che

Re: Pyhon (with wxPython) on Windows' cygwin: can it be done fully ?

2008-12-01 Thread J. Cliff Dyer
On Sat, 2008-11-29 at 13:31 -0800, Lie wrote: > pdb and logging is too much for beginners, which most likely does not > yet understand the workings of the debugger and logger (and pdb's many > quirks). Don't forget that we're all beginners once. Python's learning > curve shouldn't raise with time,

Re: pydoc enforcement.

2008-12-02 Thread J. Cliff Dyer
as just a thought. > > Ken > > > > On Tue, Dec 2, 2008 at 3:03 AM, J. Cliff Dyer <[EMAIL PROTECTED]> > wrote: > > > On Sun, 2008-11-30 at 16:27 -0800, [EMAIL PROTECTED] > wrote: > > I've been thinking abo

Re: "as" keyword woes

2008-12-08 Thread J. Cliff Dyer
On Wed, 2008-12-03 at 21:42 -0800, Warren DeLano wrote: > Anyway, it seems obvious that the right decision for our customers (or > more importantly, for their countless lines of autogenerated-Python > log, > state, and code files from the past decade) is to stick with C/Python > 2.5.x for the time

Re: how to get a beep, OS independent ?

2008-12-08 Thread J. Cliff Dyer
On Sun, 2008-12-07 at 21:13 +, Peter Pearson wrote: > On Sun, 07 Dec 2008 00:40:53 +0100, Stef Mientki wrote: > > > > I want to give a small beep, > > for windows there's message-beep, > > and there seems to be something like " curses" , > > but that package seems to be totally broken in P2.5

Re: Learning Python now coming from Perl

2008-12-09 Thread J. Cliff Dyer
On Sun, 2008-12-07 at 11:05 +0900, Bertilo Wennergren wrote: > Aahz wrote: > > > In article <[EMAIL PROTECTED]>, > > > Bertilo Wennergren <[EMAIL PROTECTED]> wrote: > > >> I don't suppose there is any introductory material out there that is > >> based on Python 3000 and that is also geared at

Re: newbie question: if var1 == var2:

2008-12-12 Thread J. Cliff Dyer
On Thu, 2008-12-11 at 13:44 -0600, Kirk Strauser wrote: > At 2008-12-11T17:24:44Z, [email protected] writes: > > > >>> ' ab c \r\n'.rstrip('\r\n') > > ' ab c ' > > >>> ' ab c \n'.rstrip('\r\n') > > ' ab c ' > > >>> ' ab c '.rstrip('\r\n') > > ' ab c ' > >

Re: Removing None objects from a sequence

2008-12-15 Thread J. Cliff Dyer
On Mon, 2008-12-15 at 02:11 +, Lie Ryan wrote: > On Fri, 12 Dec 2008 22:55:20 +, Steven D'Aprano wrote: > > > On Fri, 12 Dec 2008 21:18:36 +, Lie Ryan wrote: > >> Personally, I'd prefer VB's version: > >> foo IsNot bar > >> > >> or in pseudo-python > >> foo isnot bar > >> > >> since

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread J. Cliff Dyer
On Tue, 2008-12-16 at 12:27 +0200, Hendrik van Rooyen wrote: > "Dennis Lee Bieber" wrote: > > 8<- stuff blaming Davy for "aluminum" -- > > > Isn't Davy a Brit? > > No, he was a Brit. > He's dead now. > His safety lamp lives on. > It's a good thing its got that heat-sink sieve- > i

Re: help I'm getting delimited

2008-12-18 Thread J. Cliff Dyer
On Wed, 2008-12-17 at 06:28 -0800, aka wrote: > Hi John, thanks. > You're right, I didn't past the method header because I thought it > didn't matter when the input filename is hardcoded. > The try/except isn't very helpful indeed so I commented it out. > You're right I wrongly referred to the Uni

Re: Factoring Polynomials

2008-12-18 Thread J. Cliff Dyer
On Thu, 2008-12-18 at 11:52 -0800, eric wrote: > On Dec 18, 8:37 pm, [email protected] wrote: > > I am trying to write a simple application to factor polynomials. I > > wrote (simple) raw_input lines to collect the a, b, and c values from > > the user, but I dont know how to implement the qua

Re: confused about __str__ vs. __repr__

2008-12-18 Thread J. Cliff Dyer
On Thu, 2008-12-18 at 13:35 -0500, Neal Becker wrote: > Mel wrote: > > > Neal Becker wrote: > > > >> Tino Wildenhain wrote: > >> > >>> Neal Becker wrote: > Reading some FAQ, I see that __str__ is "meant for human eyes". > > But it seems that: > class X(object): > d

Re: __init__.py and package help

2009-01-05 Thread J. Cliff Dyer
On Mon, 2009-01-05 at 11:49 -0800, TechieInsights wrote: > Ok I have read all of the tutorials and documents I could find. I am > running Python 2.6 on windows. The problem I am having with packages > is that they don't show up! > > Simple example of what isn't working... > Structure- > > pyte

Re: python is great

2009-01-06 Thread J. Cliff Dyer
On Tue, 2009-01-06 at 10:36 -0700, Joe Strout wrote: > I've actually been rather frustrated by Python lately. OFF TOPIC!!! Please try to stay within the subject presented by the subject header. The subject in question is "python is great," not "python is frustrating." Speaking of which, python

Re: subclassing 'list'

2009-01-06 Thread J. Cliff Dyer
On Tue, 2009-01-06 at 12:34 -0800, akineko wrote: > Hello everyone, > > I'm creating a class which is subclassed from list (Bulit-in type). > > It works great. > However, I'm having a hard time finding a way to set a new value to > the object (within the class). > There are methods that alter a

Creating new instances of subclasses.

2009-01-07 Thread J. Cliff Dyer
eld(Field): def __new__(cls, a): return object.__new__(cls, a) Is there a cleaner way to do this? The main problem is that Field.__new__ gets in the way of properly constructing the subclasses once I've used it to select the proper subclass in the first place. Cheers, Cliff -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating new instances of subclasses.

2009-01-09 Thread J. Cliff Dyer
Thanks for the solutions everyone! I'm not sure which I'll end up using, but I think I've got a better grasp of the problem now. Cool stuff. Cheers, Cliff On Thu, 2009-01-08 at 06:52 -0800, Paul McGuire wrote: > On Jan 7, 12:00 pm, Paul McGuire wrote: > > On Jan 7,

Re: Problem with -3 switch

2009-01-09 Thread J. Cliff Dyer
On Fri, 2009-01-09 at 13:13 -0500, Steve Holden wrote: > Aivar Annamaa wrote: > >> As was recently pointed out in a nearly identical thread, the -3 > >> switch only points out problems that the 2to3 converter tool can't > >> automatically fix. Changing print to print() on the other hand is > >> ea

  1   2   3   >