Re: tough-to-explain Python

2009-07-20 Thread Simon Forman
On Jul 20, 4:00 am, greg g...@cosc.canterbury.ac.nz wrote: Calroc wrote: It may be that flawless software is an unreachable asymptote, like the speed of light for matter, but I'm (recently!) convinced that it's a goal worthy of exploration and effort. Seems to me that once you get beyond

Re: can i write a assemly language programs in python

2009-07-09 Thread Simon Forman
On Thu, Jul 9, 2009 at 3:17 AM, m.reddy prasad reddyreddy@gmail.com wrote: can any one tell me how to write assembly language programs in python...if no is there any other way to write the programs in python Reddi prasad reddy ph.no:09958083797 --

Re: gett error message: TypeError: 'int' object is not callable

2009-07-09 Thread Simon Forman
On Thu, Jul 9, 2009 at 9:42 AM, Nicknleio...@gmail.com wrote: snip    fields = line.split()    for i in range(len(fields)):        fields[i] = float(fields[i]) instead of the above code you could say: fields = [float(n) for n in in line.split()] Have fun getting back into python! :] (A lot

Re: ... remove all 0 values

2009-07-08 Thread Simon Forman
On Jul 8, 10:44 am, Daniel Austria futureb...@gmx.at wrote: Hi python - hackers, just one question. How can i remove all 0 values in a list? Sure - i can loop over it, but that s not a neat style.  list.remove() will only remove the first occurence. Doing that while no exception is raised is

Re: tough-to-explain Python

2009-07-08 Thread Simon Forman
(I wanted to reply to a few messages in one post so I quoted them all below. Let me know if this is bad etiquette.) On Jul 8, 8:23 am, kj no.em...@please.post wrote: In 5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com Simon Forman sajmik...@gmail.com writes: Frankly, I'm

Re: Newbie needs help

2009-07-07 Thread Simon Forman
On Mon, Jul 6, 2009 at 7:00 PM, nacim_br...@agilent.com wrote: Dear Python gurus, If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used? Also, I'd like to get a simulation result, like

Re: Catching control-C

2009-07-07 Thread Simon Forman
On Jul 6, 6:02 pm, Michael Mossey michaelmos...@gmail.com wrote: On Jul 6, 2:47 pm, Philip Semanchuk phi...@semanchuk.com wrote: On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: What is required in a python program to make sure it catches a   control- c on the command-line? Do some

Re: Clarity vs. code reuse/generality

2009-07-07 Thread Simon Forman
On Tue, Jul 7, 2009 at 8:51 AM, Jean-Michel Pichavantjeanmic...@sequans.com wrote: Steven D'Aprano wrote: On Tue, 07 Jul 2009 05:13:28 +, Lie Ryan wrote: When people are fighting over things like `sense`, although sense may not be strictly wrong dictionary-wise, it smells of something

Re: automatic multiprocessing

2009-07-07 Thread Simon Forman
On Jul 7, 11:08 am, Cheng Soon Ong chengsoon@inf.ethz.ch wrote: Hi all, I'm trying to automate the use of multiprocessing when it is available. The setting I have is quite simple, with a for loop where the operations inside are independent of each other. Here's a bit of code.

Re: tough-to-explain Python

2009-07-07 Thread Simon Forman
On Jul 7, 4:04 pm, kj no.em...@please.post wrote: I'm having a hard time coming up with a reasonable way to explain certain things to programming novices. Consider the following interaction sequence: def eggs(some_int, some_list, some_tuple): ... some_int += 2 ... some_list +=

Re: Tree structure consuming lot of memory

2009-07-06 Thread Simon Forman
On Mon, Jul 6, 2009 at 6:12 AM, mayank guptamooni...@gmail.com wrote: Thanks for the other possibilites. I would consider option (2) and (3) to improve my code. But out of curiosity, I would still like to know why does an object of a Python-class consume so much of memory (1.4 kb), and this

Re: question of style

2009-07-04 Thread Simon Forman
On Jul 4, 2:03 am, upwestdon upwest...@gmail.com wrote: On Jul 2, 1:23 pm, Simon Forman sajmik...@gmail.com wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first

Re: question of style

2009-07-04 Thread Simon Forman
On Jul 4, 2:10 pm, Paul Rubin http://phr...@nospam.invalid wrote: Simon Forman sajmik...@gmail.com writes: if not (self.higher and self.lower):     return self.higher or self.lower That would work too in this case, both higher and lower are expected to be either None or an object

Re: Clarity vs. code reuse/generality

2009-07-04 Thread Simon Forman
On Jul 4, 12:30 pm, kj no.em...@please.post wrote: In mailman.2611.1246721197.8015.python-l...@python.org Pablo Torres N. tn.pa...@gmail.com writes: On Sat, Jul 4, 2009 at 10:05, kjno.em...@please.post wrote: http://docs.python.org/reference/simple_stmts.html#grammar-token-asse... tmt

Re: PSP Caching

2009-07-03 Thread Simon Forman
On Jul 3, 5:18 am, Johnson Mpeirwe mjohn...@cfi.co.ug wrote: Hello All, How do I stop caching of Python Server Pages (or whatever causes changes in a page not to be noticed in a web browser)? I am new to developing web applications in Python and after looking at implementations of PSP like

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 2:09 am, Lie Ryan lie.1...@gmail.com wrote: Simon Forman wrote: On Jul 2, 3:57 pm, Scott David Daniels scott.dani...@acm.org wrote: Duncan Booth wrote: Simon Forman sajmik...@gmail.com wrote: ... if self.higher is self.lower is None: return ... As a matter of style however

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 12:56 am, Paul Rubin http://phr...@nospam.invalid wrote: Simon Forman sajmik...@gmail.com writes: Yes, but the concept of null pointers is considered kludgy these days. Seriously? kludgy?  (I really AM getting old.)  http://math.andrej.com/2009/04/11/on-programming-language

Re: Python debugger

2009-07-03 Thread Simon Forman
On Jul 3, 8:15 am, srinivasan srinivas sri_anna...@yahoo.co.in wrote: Hi, Could you suggest some python debuggers? Thanks, Srini       Love Cricket? Check out live scores, photos, video highlights and more. Click herehttp://cricket.yahoo.com Ipython has good debugger integration. --

question of style

2009-07-02 Thread Simon Forman
Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read and understand, but slightly less efficient, while the second is [marginally] harder to

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 1:44 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Simon Forman sajmik...@gmail.com wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 4:08 pm, Erik Max Francis m...@alcyone.com wrote: Simon Forman wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 3:57 pm, Scott David Daniels scott.dani...@acm.org wrote: Duncan Booth wrote: Simon Forman sajmik...@gmail.com wrote: ... if self.higher is self.lower is None: return ... As a matter of style however I wouldn't use the shorthand to run two 'is' comparisons together, I'd

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread Simon Forman
On Wed, Jul 1, 2009 at 7:48 AM, Barak, Ronron.ba...@lsi.com wrote: Hi, I think I'm up against a limitation in cStringIO.StringIO(), but could not find any clues on the web, especially not in http://docs.python.org/library/stringio.html. What I have is the following function:     def

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 9:30 pm, Paul Rubin http://phr...@nospam.invalid wrote: Simon Forman sajmik...@gmail.com writes: This code is part of a delete() method for a binary tree implementation. None is used to simulate a NULL pointer. In the case where both children are non-None the code goes

Re: getting rid of —

2009-07-02 Thread Simon Forman
On Jul 2, 4:31 am, Tep petshm...@googlemail.com wrote: On 2 Jul., 10:25, Tep petshm...@googlemail.com wrote: On 2 Jul., 01:56, MRAB pyt...@mrabarnett.plus.com wrote: someone wrote: Hello, how can I replace '—' sign from string? Or do split at that character? Getting unicode

Re: Open Source RSS Reader in Python?

2009-07-01 Thread Simon Forman
On Jul 1, 7:18 pm, Alex alex.lavoro.pro...@gmail.com wrote: I am looking for an open source RSS reader (desktop, not online) written in Python but in vain. I am not looking for a package but a fully functional software. Google: python open source (rss OR feeds) reader Any clue ? There's

Re: Flexible warning system

2009-06-29 Thread Simon Forman
On Sun, Jun 28, 2009 at 2:31 PM, Shrutarshi Basus...@basushr.net wrote: I'm writing a Python package where I have an underlying object model that is manipulated by a runtime control layer and clients that interface with this runtime. As I'm developing this i'm realizing that there are going to

Re: The Python Way for module configuration?

2009-06-29 Thread Simon Forman
On Sun, Jun 28, 2009 at 1:22 PM, kjno.em...@please.post wrote: In 87fxdlujds@benfinney.id.au Ben Finney ben+pyt...@benfinney.id.au writes: (Even if you don't want to receive email, could you please give your actual name in the ‘From’ field instead of just initials? It makes conversation

Re: Good books in computer science?

2009-06-29 Thread Simon Forman
On Sat, Jun 13, 2009 at 11:49 AM, koranthalakoranth...@gmail.com wrote: Hi all,    I do understand that this is not a python question and I apologize for that straight up.    But I am a full time follower of this group and I have seen very very brilliant programmers and solutions.    I also

Re: Creating an Instance Messenger type of application

2009-06-29 Thread Simon Forman
On Mon, Jun 29, 2009 at 12:18 PM, Elf Scripterlfscrip...@gmail.com wrote: Hello, Has anyone created an Instance Messenger in Python before, i mean a simple or Complex GUI based instance messenger? I thought about something like, the client also act as server, has it`s own listening port, but

Re: Creating an Instance Messenger type of application

2009-06-29 Thread Simon Forman
On Mon, Jun 29, 2009 at 12:44 PM, Elf Scripterlfscrip...@gmail.com wrote: Thank you for correcting my mistake. I checked google but nothing close. did you have any idea? On Mon, Jun 29, 2009 at 5:42 PM, Simon Forman sajmik...@gmail.com wrote: On Mon, Jun 29, 2009 at 12:18 PM, Elf

Re: What does Guido want in a GUI toolkit for Python?

2009-06-28 Thread Simon Forman
On Jun 27, 12:54 pm, laplacia...@gmail.com laplacia...@gmail.com wrote: I just read a blog post of Guido'shttp://neopythonic.blogspot.com/2009/06/ironpython-in-action-and-decl... and notice that he doesn't comment on what he wants in a GUI toolkit for Python. I sorta' wish he'd just come

Re: creating garbage collectable objects (caching objects)

2009-06-28 Thread Simon Forman
On Jun 28, 11:03 am, News123 news...@free.fr wrote: Hi. I started playing with PIL. I'm performing operations on multiple images and would like compromise between speed and memory requirement. The fast approach would load all images upfront and create then multiple result files. The

Re: pushback iterator

2009-05-22 Thread Simon Forman
On May 17, 10:39 am, Matus mat...@gmail.com wrote: Hallo pylist, I searches web and python documentation for implementation of pushback iterator but found none in stdlib. problem: when you parse a file, often you have to read a line from parsed file before you can decide if you

Re: Convert UNIX formated text files to DOS formated?

2009-05-12 Thread Simon Forman
On May 12, 4:39 pm, walterbyrd walterb...@iname.com wrote: I have about 150 unix formated text files that I would like to convert to dos formated. I am guessing that I loop though each file in the directory, read each line and conver the last character, then save to a file with the same name

Re: using zip() and dictionaries

2009-04-30 Thread Simon Forman
On Apr 30, 2:00 pm, Sneaky Wombat joe.hr...@gmail.com wrote: quick update, #change this line: for (k,v) in zip(header,[[]]*len(header)): #to this line: for (k,v) in zip(header,[[],[],[],[]]): and it works as expected.  Something about the [[]]*len(header) is causing the weird behavior.  

Re: don't understand namespaces...

2009-04-30 Thread Simon Forman
On Apr 30, 10:11 am, Lawrence Hanser lhan...@gmail.com wrote: Dear Pythoners, I think I do not yet have a good understanding of namespaces.  Here is what I have in broad outline form: import Tkinter Class App(Frame)       define two frames, buttons in

Re: changing URLs in webpages, python solutions?

2009-01-18 Thread Simon Forman
On Jan 18, 8:40 am, Stefan Behnel stefan...@behnel.de wrote: Simon Forman wrote: I want to take a webpage, find all URLs (links, img src, etc.) and rewrite them in-place, and I'd like to do it in python (pure python preferred.) lxml.html has functions specifically for this problem. http

changing URLs in webpages, python solutions?

2009-01-17 Thread Simon Forman
Hey folks, I'm having trouble finding this through google so I figured I'd ask here. I want to take a webpage, find all URLs (links, img src, etc.) and rewrite them in-place, and I'd like to do it in python (pure python preferred.) I know I could probably roll my own halfway decent solution in

Re: Does Python really follow its philosophy of Readability counts?

2009-01-17 Thread Simon Forman
On Jan 11, 1:22 pm, Madhusudan.C.S madhusuda...@gmail.com wrote:   I am sorry all I am not here to just blame Python. This is just an introspection of whether what I believe is right. Being a devotee of Python from past 2 years I have been writing only small apps and singing praises about

Re: Doubt on creating threads

2009-01-03 Thread Simon Forman
On Jan 3, 8:39 am, koranth...@gmail.com wrote: I was going through Python posts and this post caught my attentionhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/... quote  You have missed an important point. A well designed application does  neither create so many

Re: Returning a string

2009-01-03 Thread Simon Forman
On Jan 3, 11:20 am, Kless jonas@googlemail.com wrote: On 3 ene, 19:12, Diez B. Roggisch de...@nospam.web.de wrote: Kless schrieb: How is possible that I can print a variable, but when I use *return var* it returns an empty string http://paste.pocoo.org/show/97588/ I don't see

Re: Is it allowed to use function results as default arguments ?

2008-07-28 Thread Simon Forman
On Jul 28, 1:28 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I've a perfect working procedure, at least as far I've tested it it works perfect. But I was just experimenting with inspect, and saw that the default argument was not parsed correctly. So I wonder if this is allowed: def

Re: Tkinter canvas drag/drop obstacle

2008-06-22 Thread Simon Forman
On Jun 22, 7:41 pm, Peter Pearson [EMAIL PROTECTED] wrote: On Fri, 20 Jun 2008 13:41:35 -0300, Guilherme Polo [EMAIL PROTECTED] wrote: On Fri, Jun 20, 2008 at 1:11 PM, Peter Pearson [EMAIL PROTECTED] wrote: Tkinter makes it very easy to drag jpeg images around on a canvas, but I would like

Re: Simple and safe evaluator

2008-06-19 Thread Simon Forman
On Jun 16, 8:32 pm, bvdp [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Jun 17, 8:02 am, bvdp [EMAIL PROTECTED] wrote: Thanks. That was easy :) The change to the _ast version is left as an exercise to the reader ;) And I have absolutely no idea on how to do this. I can't even find

Re: Simple and safe evaluator

2008-06-11 Thread Simon Forman
On Jun 11, 1:25 pm, bvdp [EMAIL PROTECTED] wrote: Is there a simple/safe expression evaluator I can use in a python program. I just want to pass along a string in the form 1 + 44 / 3 or perhaps 1 + (-4.3*5) and get a numeric result. I can do this with eval() but I really don't want to subject

Re: Misuse of list comprehensions?

2008-05-21 Thread Simon Forman
On May 21, 4:36 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Simon Forman a écrit : On May 20, 8:58 am, Paul McGuire [EMAIL PROTECTED] wrote: On May 20, 10:50 am, [EMAIL PROTECTED] wrote: You don't need all those conditionals. A set differs from a list precisely in the fact

Re: Misuse of list comprehensions?

2008-05-20 Thread Simon Forman
On May 20, 8:58 am, Paul McGuire [EMAIL PROTECTED] wrote: On May 20, 10:50 am, [EMAIL PROTECTED] wrote: You don't need all those conditionals. A set differs from a list precisely in the fact that each element is unique. And since the function is expecting s to be an iterable object, it

Re: feature proposal, debug on exception

2008-05-20 Thread Simon Forman
On May 20, 5:59 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: There's an occasional question here about how to get python to launch pdb on encountering an uncaught exception. The answer is to look in some ASPN recipe and do some weird magic. I guess that works, but it's another thing to

Re: Removal of tkinter from python 3.0? [was: Fate of the repr module in Py3.0]

2008-03-20 Thread Simon Forman
On Mar 19, 11:39 pm, Daniel Fetchinson [EMAIL PROTECTED] wrote: Was looking at PEP 3108,http://www.python.org/dev/peps/pep-3108/, and saw that the repr module was slated for vaporization. I've only used the module a few times ever. I'm curious if the community wants it kept around or

finding items that occur more than once in a list

2008-03-18 Thread Simon Forman
Is there a more efficient way to do this? def f(L): '''Return a set of the items that occur more than once in L.''' L = list(L) for item in set(L): L.remove(item) return set(L) | f([0, 0, 1, 1, 2, 2, 3]) set([0, 1, 2]) --

Re: finding items that occur more than once in a list

2008-03-18 Thread Simon Forman
I love you guys, thanks! ;-) ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Big file

2008-03-12 Thread Simon Forman
On Mar 12, 5:42 pm, Andrew Rekdal [EMAIL PROTECTED] wrote: I am working in the class constructor defining elements of an application. The problem is the file is getting unmanageble and I am wanting to extend the contructor __init__ to another file. Is it possible to import directly into the

How to make rainbow RGB values?

2008-02-24 Thread Simon Forman
Hey all, I want to map an int to a color on a rainbow spectrum, i.e. for an int n in the range 0..N, low values (near 0) should map to the red end, and high values (near N) to the blue/violet end. The return values should be R, G, B tuples (well, #xx color codes, but that's not the hard

Re: How to make rainbow RGB values?

2008-02-24 Thread Simon Forman
On Feb 24, 5:09 pm, Andrew McNamara [EMAIL PROTECTED] wrote: I want to map an int to a color on a rainbow spectrum, i.e. for an int n in the range 0..N, low values (near 0) should map to the red end, and high values (near N) to the blue/violet end. [...] I've tried a simple scheme of

Re: Tkinter: Missing the last piece of the puzzle

2008-02-23 Thread Simon Forman
On Feb 23, 9:00 am, [EMAIL PROTECTED] wrote: I have a simple editor built into my visual parser. It has a File menu with typical New, Open, Save, Save As ... options. I now know how to set the options [en/dis]abled and how to check the Text widget's modified flag. Now I want to [en/dis]able

Re: Odd behavior in Python/Tkinter?

2007-12-21 Thread Simon Forman
On Dec 21, 12:30 pm, Lie [EMAIL PROTECTED] wrote: Inspect the following code: --- start of code --- import Tkinter as Tk from Tkconstants import * root = Tk.Tk() e1 = Tk.Entry(root, text = 'Hello World') e2 = Tk.Entry(root, text = 'Hello World') e1.grid(row = 1, column = 1)

Re: Newbie edit/compile/run cycle question

2007-12-10 Thread Simon Forman
On Dec 8, 6:45 pm, 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 syntaxcheck a saved python script without running it? Perhaps oversimplifying a bit,

Re: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread Simon Forman
On Dec 10, 6:10 am, Nikos Vergas [EMAIL PROTECTED] wrote: Challenge: A valid response will be either a solution to the problem below, or a link to some code of which you are particularly proud. Problem: In the dynamic language of your choice, write a short program that will: 1.

Re: Tkinter text widget

2007-10-07 Thread Simon Forman
On Oct 6, 11:18 pm, goldtech [EMAIL PROTECTED] wrote: I thought the DISABLED made it so I could not edit it. But it also makes it so I can not scroll down. If you make the window smaller than the content then try to put a cursor in there to use up/down arrow you can't. What I want is not to

cute use of lambda

2007-09-27 Thread Simon Forman
class FakeQueue(list): put = list.append get = lambda self: self.pop(0) ;] -- http://mail.python.org/mailman/listinfo/python-list

Matplotlib TkAgg WindowsXP ImportError

2007-09-26 Thread Simon Forman
Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more

Re: Matplotlib TkAgg WindowsXP ImportError

2007-09-26 Thread Simon Forman
On 9/26/07, Simon Forman [EMAIL PROTECTED] wrote: Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32

Re: Matplotlib TkAgg WindowsXP ImportError

2007-09-26 Thread Simon Forman
On Sep 26, 1:19 pm, Simon Forman [EMAIL PROTECTED] wrote: Hello, I just installed Matplotlib (and NumPy) on a windows XP machine, and I'm getting the following traceback when I try to use the TkAgg backend. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel

Re: Tkinter pack difficulty

2007-09-17 Thread Simon Forman
Thanks everyone for the incredibly helpful replies! I got the effect I wanted, no problem. I don't know why I didn't think to remove the expand option. I thought the sticky option would constrain the expansion. Thanks again, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Tkinter pack difficulty

2007-09-12 Thread Simon Forman
Hi all, I realize this is more of a Tk question than a python one, but since I'm using python and don't know Tcl/Tk I figured I'd ask here first before bugging the Tcl folks. I am having a terrible time trying to get a pack() layout working. I have three frames stacked top to bottom and

Re: What is the most efficient way to test for False in a list?

2007-07-08 Thread Simon Forman
On Jul 8, 7:43 pm, lex [EMAIL PROTECTED] wrote: Of course there is the always the iteration method: list = [1, True, True, False, False, True] status = True for each in list: status = status and each but what is your best way to test for for False in a list? False in list i.e.

Re: return tuple from C to python (extending python)

2006-10-24 Thread Simon Forman
Kiran wrote: Hi all, I want to make python call some C functions, process them and return them. Ok, I got all the wrapper functions and everything setup right. Here is my problem. What I need to do is to return a tuple from C to python. To go about doing this, I first create a tuple

Re: Sending Dictionary via Network

2006-10-24 Thread Simon Forman
mumebuhi wrote: Thank you very much for the reply. Can pickle work directly with socket? The way I am doing right now is to pickle the object to a file then send the file content through the socket. Pickle aso has dumps() and loads() to work with strings rather than files. Peace, ~Simon

Re: print dos format file into unix format

2006-10-22 Thread Simon Forman
[EMAIL PROTECTED] wrote: Suppose I have a dos format text file. The following python code will print ^M at the end. I'm wondering how to print it in unix format. fh = open(options.filename) for line in fh.readlines() print line, Thanks, Peng Python ships with two utility scripts,

Re: Is x.f() ==MyClass.f(x) a kind of algebraic structure?

2006-10-22 Thread Simon Forman
steve wrote: I thought that when read Guido van Rossum' Python tutorial.What can we think that? What? -- http://mail.python.org/mailman/listinfo/python-list

Re: Customize the effect of enumerate()?

2006-10-22 Thread Simon Forman
Dustan wrote: Can I make enumerate(myObject) act differently? class A(object): def __getitem__(self, item): if item 0: return self.sequence[item-1] elif item 0: return self.sequence[item] elif item == 0:

Re: invert or reverse a string... warning this is a rant

2006-10-20 Thread Simon Forman
rick wrote: ... see that the sequence is reversed. Backwards is pure, simple and easy. This is not so in Python and it should be. foo[::-1] isn't pure, simple and easy? It derives cleanly from the slice notation, it does exactly what you want, and it even works with lists and tuples and any

Re: I like python.

2006-10-20 Thread Simon Forman
Fidel wrote: Renaming the file doesn't work. I am on windows... Are you sure? Double-clicking on a *.pyw script file really brings up a window? Is it a GUI window or a console window? I ask because if it's a console window and you're really clicking on a .pyw file then it really should run

Re: Random Drawing Simulation -- performance issue

2006-09-12 Thread Simon Forman
Brendon Towle wrote: I need to simulate scenarios like the following: You have a deck of 3 orange cards, 5 yellow cards, and 2 blue cards. You draw a card, replace it, and repeat N times. So, I wrote the following code, which works, but it seems quite slow to me. Can anyone point out some

Re: convert loop to list comprehension

2006-09-09 Thread Simon Forman
[EMAIL PROTECTED] wrote: snip Thanks for that, Carl. I think that using the loop is probably what I'll end up doing. I had no idea that the listcomp thing would be quite a complicated as it is appearing. I had it in my mind that I was missing some obvious thing which would create a simple

Re: Map with an extra parameter

2006-09-09 Thread Simon Forman
ml1n wrote: [EMAIL PROTECTED] wrote: This may be what you need: class foo: def __init__(self, a, b): self.a = a self.b = b vars = [1,2,3,4,5,6] objects = [foo(a, 1) for a in vars] Note that in Python the new is expressed wit the () at the end: f = new

Re: CONSTRUCT -

2006-09-05 Thread Simon Forman
Fredrik Lundh wrote: Simon Forman wrote: I'm sorry, your post makes very little sense. you're somewhat new here, right ? ;-) /F Yah, I've been posting here about three months now. Why, did I miss something? :-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: CONSTRUCT -

2006-09-02 Thread Simon Forman
lazaridis_com wrote: I would like to fulfill the following task: The construct: if __name__ == '__main__': should be changed to something like: if identifier.name == '__main__': The term identifier should be selected based on the meaning of the __double-underscore-enclosure__ of the

Re: Syntax suggestion.

2006-09-01 Thread Simon Forman
samir wrote: Bonan tagon! George Sakkis wrote: It's been done; it's called IPython: http://ipython.scipy.org/doc/manual/manual.html Thank you for the link! It's just what I've needed but... Roberto Bonvallet wrote : ...so finally you get something that is exactly like any Unix

Re: pictures as characters in a Tk text box?

2006-09-01 Thread Simon Forman
Jay wrote: This may be really obscure, but I had a dream about programming something like this, so don't blame me. Is it possible to take a small image or icon and display it as a character in a Tk text box? Think how Thunderbird displays text smilies as actual smiley icons. Or how in AIM

Re: disgrating a list

2006-09-01 Thread Simon Forman
jwaixs wrote: Thank you for all your reply and support. Neil's fits the most to me. I shrinked it to this function: def flatten(x): for i in range(len(x)): if isinstance(x[i], list): x[i:i+1] = x[i] Thank you all again. If someone could find even a cuter way, I'd

Re: Assignment-in-conditional

2006-08-31 Thread Simon Forman
xamdam wrote: Thanks for the FAQ, and for the 'casm ;) What do you think about using alternative syntax (something like 'as') - max Fredrik Lundh wrote: xamdam wrote: I am not sure if this came up before, but I would love to have an 'assignment-in-conditional' form in python, e.g

Re: psycopg2 features

2006-08-30 Thread Simon Forman
Maxim Sloyko wrote: Hello, clp and all people reading it! Recently I was porting my (small) app from psycopg to psycopg2 (they got me with this 2). I read, that psycopg2 supports all features of psycopg and plus many more, however, when I started to port, I discovered, that psycopg2 lacks

Re: TNEF decoder

2006-08-30 Thread Simon Forman
Hendrik van Rooyen wrote: Simon Forman [EMAIL PROTECTED] wrote: 8- | A place I once worked at had a project that included some TNEF | handling. There was one developer assigned fulltime to it. He was the | one who sat at his desk hurling curses at his

Re: Is this a good idea or a waste of time?

2006-08-29 Thread Simon Forman
Antoon Pardon wrote: On 2006-08-28, Scott David Daniels [EMAIL PROTECTED] wrote: Antoon Pardon wrote: On 2006-08-25, Simon Forman [EMAIL PROTECTED] wrote: ... Generally asserts should be used to enforce invariants of your code (as opposed to typechecking), or to check certain things

Re: naive misuse? (of PyThreadState_SetAsyncExc)

2006-08-29 Thread Simon Forman
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: The documentation for PyThreadState_SetAsyncExc says To prevent naive misuse, you must write your own C extension to call this. Anyone care to list a few examples of such naive misuse? No? I'll take that then as proof that it's impossible

Re: newbe question about removing items from one file to another file

2006-08-29 Thread Simon Forman
[EMAIL PROTECTED] wrote: Anthra Norell wrote: Dexter, I looked at the format specification. It contains an example: --- CsoundSynthesizer; ; test.csd - a Csound structured data file CsOptions -W -d -o tone.wav /CsOptions

Re: subprocess woes

2006-08-29 Thread Simon Forman
Dennis Lee Bieber wrote: On Tue, 29 Aug 2006 18:17:47 +0530, km [EMAIL PROTECTED] declaimed the following in comp.lang.python: ##code start ## import subprocess as sp x = 'GSQIPSHYWKKNLWYYSHEIDGGCHNMW' p0 = sp.Popen([echo,x], stdout=sp.PIPE) Why use this at all? p1 =

Re: TNEF decoder

2006-08-29 Thread Simon Forman
David Isaac wrote: I'm aware of http://cheeseshop.python.org/pypi/pytnef/ but it uses the tnef utility, and I'd like a pure Python solution (along the lines of http://www.freeutils.net/source/jtnef/ ). Is there one? Thanks, Alan Isaac A place I once worked at had a project that included

Re: newbe question about removing items from one file to another file

2006-08-28 Thread Simon Forman
[EMAIL PROTECTED] wrote: def simplecsdtoorc(filename): file = open(filename,r) alllines = file.read_until(/CsInstruments) pattern1 = re.compile(/) orcfilename = filename[-3:] + orc for line in alllines: if not pattern1 print orcfilename, line I am

Re: Firewire comms using Python?

2006-08-28 Thread Simon Forman
Fraggle69 wrote: Hi, Does anyone have any idea of how I can use Python to get images from my firewire camera?? I am using python under winXP pro Cheers Fraggle Have you tried google? Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Segmentation Fault

2006-08-28 Thread Simon Forman
[EMAIL PROTECTED] wrote: Simon Forman [EMAIL PROTECTED] writes: pycraze wrote: I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our testcases we

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Simon Forman
Andrew Robert wrote: Simon Forman wrote: Paul Rubin wrote: EP [EMAIL PROTECTED] writes: Given that I am looking for matches of all files against all other files (of similar length) is there a better bet than using re.search? The initial application concerns files in the 1,000's, and I

Re: Firewire comms using Python?

2006-08-28 Thread Simon Forman
PetDragon wrote: yeah man no joy there Simon Forman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Fraggle69 wrote: Hi, Does anyone have any idea of how I can use Python to get images from my firewire camera?? I am using python under winXP pro Cheers Fraggle

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Simon Forman
Andrew Robert wrote: Because I was lazy.. The checksume_compare came from something else I wrote that had special logging and e-mailer calls in it. Should have ripped the reference to caller and file name out.. Aaaahh the subtle joys of cut-and-paste programming... :-D (I've done it

Re: Twisted server and protocol question

2006-08-28 Thread Simon Forman
Benry wrote: Hi guys. I hope I can discuss Twisted here. If not, direct me to the correct place please. Twisted mailing list: http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python ;-) ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching for text

2006-08-28 Thread Simon Forman
robinsiebler wrote: The other thing I failed to mention is that I need to ensure that I find the fsType *before* I find the next FontName. Given these requirements, I'd formulate the script something like this: f = open(filename) NUM_LINES_BETWEEN = 7 Fo = '/FontName /ACaslonPro-Semibold'

Re: eval() woes

2006-08-28 Thread Simon Forman
rdrink wrote: Hey Simon, Thanks for the reply. Simon Forman wrote: You must be doing something weird, that equation works for me: Try posting the minimal code example that causes the error and the full, exact traceback that you get. I appreciate the offer... but at this point my code

Re: eval() woes

2006-08-28 Thread Simon Forman
rdrink wrote: Ok, maybe now I can make some more sense of this, with an example of real code (sorry if it's a bit dense): This is the basic function... def equate(parts,new_eq): oL = int(parts[0]) iL = int(parts[1]) iR = int(parts[2]) oR = int(parts[3])

<    1   2   3   4   5   >