SHPAML v0.1 -- HAML-like language for Python

2009-12-11 Thread Steve Howell
been well tested in practice already and is feature-complete for its fairly minimal goals as of now. The site has a link to a mailing list (Google Groups) for further discussion, if this interests you! Thanks, Steve Howell -- http://mail.python.org/mailman/listinfo/python-announce-list

Re: SHPAML v0.1 -- HAML-like language for Python

2009-12-25 Thread Steve Howell
, Steve Howell On Dec 11, 5:10 am, Steve Howell showel...@yahoo.com wrote: SHPAML is a HAML-like language for Python.  If you are not familiar with HAML, it is a markup language implemented in Ruby that allows you to create web pages with an indentation-based syntax.  SHPAML is not an exact

Re: Inter-process communication, how?

2007-12-15 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: TCP/IP sounds good but isn't it a bit too heavy? It depends on your judgment, of course. On a simplistic level, using TCP/IP shouldn't be any more work than what you'd do if you were reading and writing files, especially if everything you're doing is on the same

a Python person's experience with Ruby

2007-12-07 Thread Steve Howell
Python is my favorite programming language. I've used it as my primary language for about six years now, including four years of using it full-time in my day job. Three months ago I decided to take a position with a team that does a lot of things very well, but they don't use Python. We use

Re: Python is not a good name, should rename to Athon

2007-12-08 Thread Steve Howell
--- Jan Claeys [EMAIL PROTECTED] wrote: Op Mon, 03 Dec 2007 14:20:52 +1300, schreef greg: If you want a really appropriate name for a programming language, I'd suggest Babbage. (not for Python, though!) Konrad Zuse wrote the first high-level programming language, so I think his

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers [EMAIL PROTECTED] wrote: Colin J. Williams a écrit : I'm not sure that I like add 3, 5, 7 but it would be nice to be able to drop the parentheses when no argument is required. Thus: close; could replace close(); This just could not work given

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: What don't I know that I should know to just edit/run, preferably at the tap of a function key? Most good editors let you do these things: 1) Save a file. 2) Run a script from the shell. 3) Turn steps 1 and 2 into a macro. 4) Allow you to map the

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : I'm a java guy used to the effective edit/run cycle you get with a good IDE. Today I'm writing my first Python, but can't seem to find the way to use Python's inherent edit/run cycle. Use an IDE

Re: Ruby's Template Engine for Python

2007-12-08 Thread Steve Howell
--- Samuel [EMAIL PROTECTED] wrote: Hi, Following the masses I was drawn to RoR's website today and I saw the following HTML template in one of the screencasts: I know a lot of Rails goodies have been ported to Python, so you might want to google some variations on form_remote_tag

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Bruno Desthuilliers Another aspect of Ruby is that the final expression evaluated in a method actually gets returned as the result of a method, Unless there's an explict return before... which has further implications on whether close is simply evaluated or called. I'm

Re: a Python person's experience with Ruby

2007-12-08 Thread Steve Howell
--- Richard Jones [EMAIL PROTECTED] wrote: class A(object): def set_a(self, value): self._a = value a = property(lambda self: self._a, set_a) Note that this differs from a regular attribute because a is not deletable from instances (the property defines no deleter).

Re: auto-increment operator - why no syntax error?

2007-12-08 Thread Steve Howell
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 08 Dec 2007 16:58:25 -0800, Karthik Gurusamy wrote: Why are the following accepted even without a warning about syntax error? (I would expect the python grammar should catch these kind of syntax errors) 2 * + n

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Jeremy C B Nicoll [EMAIL PROTECTED] wrote: Steve Howell [EMAIL PROTECTED] wrote: There are a zillion powerful editors out there. I've been productive in EditPlus, MultiEdit, SlickEdit, vim, and emacs, just to throw out a few examples. What command (in XP) does one need to issue

Re: Advice for editing xml file using ElementTree and wxPython

2007-12-08 Thread Steve Howell
--- Rick Muller [EMAIL PROTECTED] wrote: If I want to do this, it seems like I need to keep a connection between the gui element and the original value in the elementtree, so I can update it. But I'm having a hard time visualizing exactly how this works. Can someone help me out here a

Re: Newbie edit/compile/run cycle question

2007-12-08 Thread Steve Howell
--- Jeremy C B Nicoll [EMAIL PROTECTED] wrote: Steve Howell [EMAIL PROTECTED] wrote: --- Jeremy C B Nicoll [EMAIL PROTECTED] wrote: What command (in XP) does one need to issue to syntax check a saved python script without running it? Perhaps oversimplifying a bit

Re: Serializing Python compiled code.

2007-12-09 Thread Steve Howell
--- [EMAIL PROTECTED] wrote: In a C++ application having a Python interpreter embedded, is it possible to compile a small Python snippet into object code and serialize the compiled object code to, for example, a database? I am exploring the possibility of writing a data driven

Re: reading list of list to a file

2007-12-09 Thread Steve Howell
--- caroliina [EMAIL PROTECTED] wrote: i made a list of lists but i cant write it into a file. how do i get the first string in a sublist? -- Try doing this: print list_of_lists print list_of_lists[0] print list_of_lists[0][0] print list_of_lists[0][0][0] It might give you some

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
After starting this discussion thread, I found the link below: http://www.b-list.org/weblog/2006/jun/18/lets-talk-about-python-and-ruby/ If you're like me--struggling to learn Ruby while having Python as your primary point of reference--you might find some of the points informative. I suspect

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- MonkeeSage [EMAIL PROTECTED] wrote: Not just callable, but interchangeable. My point was that in ruby, if you use a block or a lambda as a HOF, you have to use #call / #[] / yield keyword on it to call it. def foo(a) puts a end bar = lambda { | a | puts a } # these do the

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie [EMAIL PROTECTED] wrote: self.feed = self.config['feedsrc'] self.numfeeds = self.config['numfeeds'] self.numlines = self.config['numlines'] self.w = 520 self.h = 12*self.numfeeds*(self.numlines+1)

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie [EMAIL PROTECTED] wrote: OK, sorry, this was about indents. Stupid VIM! No prob. Add something like this (untested) to your ~/.vimrc: set expandtab set sw=4 set ts=4 Looking for

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell
--- CoolGenie [EMAIL PROTECTED] wrote: OK, sorry, this was about indents. Stupid VIM! One more piece of VIM advice. You can use set list to show where tabs are. I prefer to convert my own tabs to spaces automatically, but you inevitably come across code that you don't own where it's nice to

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- Bruno Desthuilliers [EMAIL PROTECTED] wrote: Steve Howell a écrit : (snip) Jordan and others, thanks for all your posts; I am learning a lot about both languages. This is what I've gathered so far. Python philosophy: passing around references to methods should

Re: a Python person's experience with Ruby

2007-12-09 Thread Steve Howell
--- MonkeeSage [EMAIL PROTECTED] wrote: On Dec 9, 6:23 pm, MonkeeSage [EMAIL PROTECTED] wrote: Hi Bruno, I think that we've been having a mainly semantic (pun intended) dispute. I think you're right, that we've been using the same words with different meanings. I think Ruby and

Re: Distinguishing attributes and methods

2007-12-09 Thread Steve Howell
--- Jan Claeys [EMAIL PROTECTED] wrote: To conclude this discussion: * in Python, methods are attributes * in Ruby, attributes are methods So clearly one of the languages has it all wrong. ;)

ten small Python programs

2007-05-26 Thread Steve Howell
I've always thought that the best way to introduce new programmers to Python is to show them small code examples. When you go to the tutorial, though, you have to wade through quite a bit of English before seeing any Python examples. Below is my attempt at generating ten fairly simple,

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: Very cool! Do you mind putting this up on the Wiki somewhere so that we can link to it more easily? Maybe something like: http://wiki.python.org/moin/SimplePrograms Done. nitpick Though the code should probably follow PEP 8

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Paul McGuire [EMAIL PROTECTED] wrote: I ***love*** this 10 Little Programs idea! As soon as I get a breathing space, I'm going to add a 10 Little Parsers page to the pyparsing wiki! Thanks. :) I'm thinking you could actually have a progression from a 1 line program up to a 50-line

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Paul McGuire [EMAIL PROTECTED] wrote: On May 26, 8:48 pm, Steve Howell [EMAIL PROTECTED] wrote: I'm thinking you could actually have a progression from a 1 line program up to a 50-line program. The number 50 is kind of arbitrary, but my gut says that by a 50-line program, you

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 26 May 2007 18:48:45 -0700, Steve Howell wrote: It also has a ComplexNumber class, but I don't want to scare away mathphobes. Is it as short as this one-liner? ComplexNumber = complex The It above refers to *the* Python

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven D'Aprano wrote: On Sat, 26 May 2007 18:48:45 -0700, Steve Howell wrote: It also has a ComplexNumber class, but I don't want to scare away mathphobes. Is it as short as this one-liner? ComplexNumber = complex Along the idea of not reinventing a class from

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Steve Howell
--- Ben Finney [EMAIL PROTECTED] wrote: Paul McGuire [EMAIL PROTECTED] writes: At this point, I realized that I was taking things too far off-topic, so I decided to start a new thread. So, uh, what's the purpose of this thread? Did you have a specific point to start off with, or a

Re: totally lost newbie

2007-05-27 Thread Steve Howell
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Maybe it's easier to use a key function instead of a compare function. A key function receives an element and must return something that is then sorted and the element ends up where the computed key is in the sorted list. Little

Re: totally lost newbie

2007-05-27 Thread Steve Howell
--- mark [EMAIL PROTECTED] wrote: Hi all I posted earlier on this but have changed my approach so here is my latest attempt at solving a problem. I have been working on this for around 12 hours straight and am still struggling with it. Write a program that reads the values for a

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Eric [EMAIL PROTECTED] wrote: I have some working code, but I realized it is just the way I would write it in C, which means there is probably a better (more pythonic) way of doing it. Here's the section of code: accumulate = firstIsCaps = False accumStart = i = 0

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-27 Thread Steve Howell
--- Gabriel Genellina [EMAIL PROTECTED] wrote: Underscores are not always easily available on non us-layout keyboards, like \ and @ and many other special characters. A language that requires more symbols than the 26 english letters has to make room somewhere - keyboards usually

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener [EMAIL PROTECTED] wrote: On May 26, 1:43 pm, Steve Howell [EMAIL PROTECTED] wrote: -- # def defines a method in Python def tax(itemCharge, taxRate = 0.05): return itemCharge * taxRate print '%.2f' % tax(11.35) print '%.2f' % tax

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener [EMAIL PROTECTED] wrote: For the person new to programming (doesn't come from C or other languages), I think you need to add a separate explanation of string formatting and how it works, or at least add a comment that tells them you are using string formatting so

Re: PHP5 programmer learning Python

2007-05-27 Thread Steve Howell
--- romiro [EMAIL PROTECTED] wrote: Anyway, my first question was if anyone knows of a tutorial that focuses on PHP - Python learning, in such that there might be a block of PHP code alongside an example of how to do the same thing in Python. I know exactly what you mean, and I

Re: PHP5 programmer learning Python

2007-05-27 Thread Steve Howell
--- romiro [EMAIL PROTECTED] wrote: I've recently tried C#, a very short lived re-attempt at C++ and Java, and Ruby. To the extend that you're familiar with C++/Java/Ruby, you may find this link as an interesting way to see how Python looks: http://www.dmh2000.com/cjpr/cmpframe.html

Re: Why isn't this query working in python?

2007-05-27 Thread Steve Howell
--- erikcw [EMAIL PROTECTED] wrote: ('SELECT payment_id FROM amember_payments WHERE member_id=%s AND expire_date NOW() AND completed=1 AND (product_id 11 AND product_id 21)', (1608L,)) () Here is a copy of the table schema and the first 2 rows. Does your table actually

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Wildemar Wildenburger [EMAIL PROTECTED] wrote: Steve Howell wrote: # def defines a method in Python def say_hello(name): print 'hello', name say_hello('Jack') say_hello('Jill') Doesn't def define methods *xor* functions, depending on the context

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud [EMAIL PROTECTED] wrote: Bejeezus. The description of groupby in the docs is a poster child for why the docs need user comments. Can someone explain to me in what sense the name 'uniquekeys' is used this example: [...] The groupby method has its uses, but it's behavior is

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud [EMAIL PROTECTED] wrote: Bejeezus. The description of groupby in the docs is a poster child for why the docs need user comments. I would suggest an example with a little more concreteness than what's currently there. For example, this code... import itertools syslog_messages

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: I think I would rewrite the current unit-testing example to use the standard library unittest module:: # Let's write reusable code, and unit test it. def add_money(amounts): # do arithmetic in pennies so as not to

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: I think I would rewrite the current unit-testing example to use the standard library unittest module:: # Let's write reusable code, and unit test it. def add_money(amounts): # do arithmetic in pennies so as not to

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- 7stud [EMAIL PROTECTED] wrote: I'd settle for a simple explanation of what it does in python. The groupby function prevents you have from having to write awkward (and possibly broken) code like this: group = [] lastKey = None for item in items: newKey = item.key()

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Steve Howell [EMAIL PROTECTED] wrote: --- 7stud [EMAIL PROTECTED] wrote: Bejeezus. The description of groupby in the docs is a poster child for why the docs need user comments. Regarding the pitfalls of groupby in general (even assuming we had better documentation), I

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: Steve Howell wrote: --- Steven Bethard [EMAIL PROTECTED] wrote: I think I would rewrite the current unit-testing example to use the standard library unittest module:: # Let's write reusable code, and unit test it. def

unit testing

2007-05-27 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: Have you tried py.test? http://codespeak.net/py/dist/test.html I've heard good things about it, but haven't gotten around to trying it yet. Here's a two-line test suite from the page above: def test_answer(): assert 42

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard [EMAIL PROTECTED] wrote: Maybe this is the first good example that motivates a hyperlink to alternatives. Would you accept the idea that we keep my original example on the SimplePrograms page, but we link to a UnitTestingPhilosophies page, and we show your

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- paul [EMAIL PROTECTED] wrote: Regarding the pitfalls of groupby in general (even assuming we had better documentation), I invite people to view the following posting that I made on python-ideas, entitled SQL-like way to manipulate Python data structures: LINQ? Maybe. I

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Carsten Haese [EMAIL PROTECTED] wrote: On Sun, 2007-05-27 at 10:17 -0700, 7stud wrote: Bejeezus. The description of groupby in the docs is a poster child for why the docs need user comments. Can someone explain to me in what sense the name 'uniquekeys' is used this example:

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- John Machin [EMAIL PROTECTED] wrote: (And you can ignore the fact that it won't find a sequence at the very end of words, that is fine for my purposes). [...] Bzzzt. Needs the following code at the end: if accumulator: doSomething(accumulator) FWIW the OP already

Re: Newbie question - better way to do this?

2007-05-27 Thread Steve Howell
--- Steven D'Aprano wrote: On Sun, 27 May 2007 14:55:42 -0700, John Machin wrote: Bzzzt. Bzzzt! Can we please refrain from buzzer sounds in this mostly civil forum, even if one beep deserves another?

Re: unit testing

2007-05-27 Thread Steve Howell
Let me preface every reply here by YMMV. I strongly, strongly encourage people to tap into the unit testing community for all tools that are available to them. Also, let me say that despite any place where Steven and I disagree about the mechanics of unit testing, we're in firm agreement that

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Carsten Haese [EMAIL PROTECTED] wrote: [...] It's an abstract code pattern for an abstract use case. I question the use of abstract code patterns in documentation, as they just lead to confusion. I really think concrete examples are better in any circumstance. Also, to the OP's

Re: itertools.groupby

2007-05-27 Thread Steve Howell
--- Raymond Hettinger [EMAIL PROTECTED] wrote: FWIW, I wrote those docs. Suggested improvements are welcome; however, I think they already meet a somewhat high standard of quality: I respectfully disagree, and I have suggested improvements in this thread. Without even reading the

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen [EMAIL PROTECTED] wrote: Steve Howell skrev: def firstIsCapitalized(word): return 'A' = word[0] = 'Z' For someone who is worried about the impact of non-ascii identifiers, you are making surprising assumptions about the contents of data. The function

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger [EMAIL PROTECTED] wrote: + The operation of \function{groupby()} is similar to the \code{uniq} filter + in \UNIX{}. [...] Thanks! The comparison of groupby() to uniq really clicks with me. To the extent that others like the Unix command line analogy for

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Paul Rubin http://phr.cx@NOSPAM.invalid wrote: [...] Here's yet another example that came up in something I was working on: you are indexing a book and you want to print a list of page numbers for pages that refer to George Washington. If Washington occurs on several consecutive

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-28 Thread Steve Howell
--- Roy Smith [EMAIL PROTECTED] wrote: It's certainly easier to parse ip_address as compared to IPAddress. Same with snmp_manager vs SNMPManager. Somebody earlier was actually advocating something called proper_case, in which you can capitalize certain letters for clarity, like

Re: Newbie question - better way to do this?

2007-05-28 Thread Steve Howell
--- Nis Jørgensen [EMAIL PROTECTED] wrote: I disagree that word.istitle is the correct idiom - from the naming of the function in the original example, I would guess word[0].isupper would do the trick. nitpick That would return something like this: built-in method isupper of str

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki [EMAIL PROTECTED] wrote: Steve Howell wrote: I've always thought that the best way to introduce new programmers to Python is to show them small code examples. This is really a nice piece of missing Python. Thanks. The wxPython demo program is written

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Carsten Haese [EMAIL PROTECTED] wrote: On Sun, 2007-05-27 at 18:12 -0700, Steve Howell wrote: [...] there is no way that uniquekeys is a sensible variable [...] That's because the OP didn't heed the advice from the docs that Generally, the iterable needs to already be sorted

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger [EMAIL PROTECTED] wrote: That's not for everyone, so it isn't a loss if someone sticks with writing plain, clear everyday Python instead of an itertool. I know most of the module is fairly advanced, and that average users can mostly avoid it, but this is a very

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki [EMAIL PROTECTED] wrote: It would even be nicer, if everybody could drop her/his examples in a standard way, so they would be automatically incorporated in something like the wxPython interactive demo. Can you elaborate? Well if you see the above demo,

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki [EMAIL PROTECTED] I don't know MoinMoin, but the answer is Yes (although maybe not for your ten snippets). First of all I think all programmers keep there own collection of code snippets, which much more valuable then all the code code snippets from everyone. Agreed.

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Paul Rubin http://phr.cx@NOSPAM.invalid wrote: But that is what groupby does, except its notion of uniqueness is limited to contiguous runs of elements having the same key. It occurred to me that we could also rename the function uniq(), or unique(), after its Unix counterpart, but

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Raymond Hettinger [EMAIL PROTECTED] wrote: That's not for everyone, so it isn't a loss if someone sticks with writing plain, clear everyday Python instead of an itertool. I know most of the module is fairly advanced, and that average users can mostly avoid it, but this is

Re: itertools.groupby

2007-05-28 Thread Steve Howell
--- Alex Martelli [EMAIL PROTECTED] wrote: Steve Howell [EMAIL PROTECTED] wrote: ... for has_chars, frags in itertools.groupby(lines, lambda x: len(x) 0): Hmmm, it appears to me that itertools.groupby(lines, bool) should do just the same job, just a bit faster and simpler

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-29 Thread Steve Howell
--- Carsten Haese [EMAIL PROTECTED] wrote: On Sun, 2007-05-27 at 07:30 +, OKB (not okblacke) wrote: Underscores are harder to type than any alphanumeric character. This is a discussion about underscores versus capital letters denoting the word boundaries in

Re: Periodic tasks.

2007-05-29 Thread Steve Howell
--- Ramashish Baranwal [EMAIL PROTECTED] wrote: Hi, I am trying to execute some tasks periodically, those familiar with unix can think of it as equivalent to cron jobs. I have tried looking around, but couldn't find a way. Would appreciate any pointers or clues.. I'm also interested

Re: Periodic tasks.

2007-05-29 Thread Steve Howell
--- vasudevram [EMAIL PROTECTED] wrote: On May 29, 4:39 pm, Steve Holden [EMAIL PROTECTED] wrote: Alternatively, the user could make use of the already-existing sched module from the standard library. With a little threading that would do the job fine. Yes. Also, there's an

Re: itertools.groupby

2007-05-29 Thread Steve Howell
--- Carsten Haese [EMAIL PROTECTED] wrote: As an aside, while groupby() will indeed often be used in conjunction with sorted(), there is a significant class of use cases where that's not the case: I use groupby to produce grouped reports from the results of an SQL query. In such cases, I

Re: SMTPAuthenticationError

2007-05-29 Thread Steve Howell
--- Ramashish Baranwal [EMAIL PROTECTED] wrote: Are you sure that your SMTP server uses this type of authentication? Some SMTP servers use POP3 followed by SMTP to authenticate instead. use telnet to verify, this link might help.

Re: itertools.groupby

2007-05-29 Thread Steve Howell
On May 29, 2:34 am, Raymond Hettinger [EMAIL PROTECTED] wrote: The gauntlet has been thrown down. Any creative thinkers up to the challenge? Give me cool recipes. I don't make any claims to coolness, but I can say that I myself would have written the code below with significantly more

Re: itertools.groupby (gauntlet thrown down)

2007-05-29 Thread Steve Howell
Raymond Hettinger [EMAIL PROTECTED] writes: The gauntlet has been thrown down. Any creative thinkers up to the challenge? Give me cool recipes. Twin primes? (Sorry, no code, but there's a good Python example somewhere that returns an iterator that keeps doing the sieve, feed it to

Re: Examples of high-quality python code?

2007-05-30 Thread Steve Howell
--- kaens [EMAIL PROTECTED] wrote: Anyhow, I'm looking to expand my understanding of python, and I feel that one of the best ways to do that is looking at other peoples code. A lot of the built-in Python modules are implemented in pure Python. If you are using any of those so far and

Re: file reading by record separator (not line by line)

2007-05-31 Thread Steve Howell
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: There was just recently a thread with a `itertools.groupby()` solution. Yes, indeed. I think it's a very common coding problem (with plenty of mostly analogous variations) that has these very common pitfalls: 1) People often forget to

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- stef [EMAIL PROTECTED] wrote: doing a simulation of another language (JAL), I translate the other language into Python code, then I execute this converted Python code. [...] (btw the whole program is running as an graphical (wxPython) application) I worked on an open source project that

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- Diez B. Roggisch [EMAIL PROTECTED] wrote: Are there any other (simple) ways of achieving this ? (btw the whole program is running as an graphical (wxPython) application) use the python trace facilities. http://docs.python.org/lib/module-trace.html I'm not sure how much that

Re: file reading by record separator (not line by line)

2007-06-01 Thread Steve Howell
--- Tijs [EMAIL PROTECTED] wrote: Yes, or a single one that takes a wide range of construction possibilities, like strings, lambdas or regexes in various keyword parameters. BlockReader(f, start='') BlockReader(f, start=re.compile('|'), end='---') BlockReader(f, start=lambda x:

Re: file reading by record separator (not line by line)

2007-06-01 Thread Steve Howell
--- Tijs [EMAIL PROTECTED] wrote: Steve Howell wrote: [...] but I wonder if the Python community couldn't help a lot of newbies (or insufficiently caffeinated non-newbies) by any of the following: Well, I'm not a newbie, and I always make sure to be thoroughly caffeinated before

Re: subexpressions

2007-06-01 Thread Steve Howell
--- A.T.Hofkamp [EMAIL PROTECTED] wrote: lambda x: (lambda y: sin(y) + cos(y))(x*x) Elegant. I find the use of y confusing there (thinking about the unit circle), so I'd amend it to this: lambda x: (lambda x2: sin(x2) + cos(x2))(x*x) But I like the overall idea.

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- stef [EMAIL PROTECTED] wrote: the language I want to simulate (JAL), is very Pascal like, and therefor can be easily converted into equivalent Python code. One more idea. If you haven't already, maybe you can post something to the PyPy community to effect of this: ''' I have a

Re: generating a tree-like structure

2007-06-01 Thread Steve Howell
--- A.T.Hofkamp [EMAIL PROTECTED] wrote: I would probably generate a DOT file to get a 2D visualization. DOT is part of Graphviz (graphviz.org), and there are quite a few graphviz front-ends available in Python to make DOT generation easier (pydot, yapgvb, and probably a few others).

Re: execute a function after each source code line ?

2007-06-01 Thread Steve Howell
--- stef [EMAIL PROTECTED] wrote: Steve, that's exactly what I've in mind. The screen shots, looks really good, and I'll definitely will take a deeper look into your code. Cool, good luck. Feel free to contact me privately if you have questions about the implementation. There's also a

Re: subexpressions

2007-06-01 Thread Steve Howell
--- Sergey Dorofeev [EMAIL PROTECTED] wrote: What syntax would you suggest for a lambda enhanced to cover your use case? I suppose you will end up with roughly the same number of characters, all crammed in one line -- or broken into lines at a random position as it happens with

Re: subexpressions

2007-06-01 Thread Steve Howell
--- Tijs [EMAIL PROTECTED] wrote: Steve Howell wrote: FWIW there's the possibility that even without a subexpression syntax, some Python implementations would detect the duplication of x*x and optimize that for you. It would have to know that x*x had no side effects, which I think

Re: subexpressions

2007-06-01 Thread Steve Howell
--- Diez B. Roggisch [EMAIL PROTECTED] wrote: The elegance of that solution very much depends on the cost of the duplicate operation vs. the additional function call. And for the usecase at hand, that's exactly the point not to do it: [EMAIL PROTECTED]:/tmp$ python -m timeit '(lambda x:

Re: subexpressions

2007-06-01 Thread Steve Howell
--- Paul Boddie [EMAIL PROTECTED] wrote: On 1 Jun, 12:55, Steve Howell [EMAIL PROTECTED] wrote: FWIW there's the possibility that even without a subexpression syntax, some Python implementations would detect the duplication of x*x and optimize that for you. It would have to know

Re: subexpressions

2007-06-02 Thread Steve Howell
def f(x): y = x*x; return sin(y)+cos(y); Although I know valid trigonometry is not the point of this exercise, I'm still trying to figure out why anybody would ever take the square of an angle. What's the square root of pi/4 radians?

Re: subexpressions (OT: math)

2007-06-02 Thread Steve Howell
--- Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 02 Jun 2007 05:54:51 -0700, Steve Howell wrote: def f(x): y = x*x; return sin(y)+cos(y); Although I know valid trigonometry is not the point of this exercise, I'm still trying to figure out why anybody would ever take

Re: subexpressions

2007-06-02 Thread Steve Howell
--- Stef Mientki [EMAIL PROTECTED] wrote: Maybe he meant sin(x)^2 + cos(x)^2 which is well known demodulation technique if you create two signals 90 degrees out of phase. There's a shorter way to phrase that expression, of course. :) 1

Re: subexpressions (fourier example)

2007-06-02 Thread Steve Howell
--- Steve Howell [EMAIL PROTECTED] wrote: --- Stef Mientki [EMAIL PROTECTED] wrote: Maybe he meant sin(x)^2 + cos(x)^2 which is well known demodulation technique if you create two signals 90 degrees out of phase. A more realistic subexpression where you might repeat yourself

Re: file reading by record separator (not line by line)

2007-06-02 Thread Steve Howell
--- George Sakkis [EMAIL PROTECTED] wrote: It seems like it would be fairly straightforward to do a quick prototype implementation of this. I'm off to work soon, so I can't do it today, but maybe Sunday. I'm afraid I beat you to it :)

Re: file reading by record separator (not line by line)

2007-06-02 Thread Steve Howell
--- Steve Howell [EMAIL PROTECTED] wrote: Can I suggest a minor optimization? Instead of this... def get_predicate(arg): return arg if callable(arg) else ( arg.__eq__ if hasattr(arg,'__eq__') else lambda item: item == arg) Never mind, I

Re: Python rocks

2007-06-02 Thread Steve Howell
--- Mark Carter [EMAIL PROTECTED] wrote: Well, I know I'm preaching to the converted - but Python rocks. [...] A few questions from the choir: As a recent newcomer to the language, did you encounter any traps or pitfalls while you were learning? Also, could you single out anything in

iterblocks cookbook example

2007-06-02 Thread Steve Howell
George Sakkis produced the following cookbook recipe, which addresses a common problem that comes up on this mailing list: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521877 I would propose adding something like this to the cookbook example above. def iterblocks2(lst, start_delim):

  1   2   3   4   5   >