ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread Steve Howell
During the last few days I have written code in support of a small DDL language that encapsulates a concise representation of the manipulations needed to make a deep subcopy of a Python-like data structure. It is inspired by syntax from mainstream modern languages, including, of course, Python. The

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Diez B. Roggisch
Lie Ryan schrieb: hong zhang wrote: --- On Tue, 11/17/09, Tim Chase wrote: From: Tim Chase Subject: Re: IOError: [Errno 28] No space left on device To: "Lie Ryan" Cc: python-list@python.org Date: Tuesday, November 17, 2009, 7:47 PM for i in glob.glob('/sys/kernel/debug/ieee80211/phy*/iwl

Re: XML root node attributes

2009-11-18 Thread Slafs
Thanks But this doesn't work. I've ended using something like this: import xml.etree.ElementTree as ET root = ET.Element("root", dict(a='v', b='v2', c='v3')) n = ET.SubElement(root,'d') tree = ET.ElementTree(root) import sys tree.write(sys.stdout) On 17 Lis, 15:36, Stefan Behnel wrote: > Slafs

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On the topic of "switch" statements and even-more-concise-then-we-have- already if/elif/else/end constructs, I have to say that Python does occasionally force you to write code like the code below. Maybe "force" is too strong a word, but Python lends itself to if/elif blocks like below, which get

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-18 Thread Marcus Gnaß
See also http://docs.python.org/dev/3.0/whatsnew/2.6.html#pep-3110-exception-handling-changes -- http://mail.python.org/mailman/listinfo/python-list

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell wrote: > On the topic of "switch" statements and even-more-concise-then-we-have- > already if/elif/else/end constructs, I have to say that Python does > occasionally force you to write code like the code below.  Maybe > "force" is too strong a word, bu

pygtk - icons?

2009-11-18 Thread Helmut Jarausch
Hi, please bear in mind that I'm an absolute newcomer to (py)gtk. I'm trying to install the nice synchronization tool http://live.gnome.org/Conduit which is written in Python and use pyGTK. This installed several icons e.g. /usr/share/icons/hicolor/16x16/apps/conduit.png When run, Conduit fail

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 1:32 am, Chris Rebert wrote: > On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell wrote: > > On the topic of "switch" statements and even-more-concise-then-we-have- > > already if/elif/else/end constructs, I have to say that Python does > > occasionally force you to write code like the code

Re: A different take on finding primes

2009-11-18 Thread Anh Hai Trinh
> 1) google list of prime numbers > 2) see "Prime numbers list" in the results (number 3 in the results) > 3) click link that leads towww.prime-numbers.org > > I found 455042511 prime numbers in approx 15 seconds. Not bad at all. How about using http://www.sagemath.org/ (written in Python). s

Re: TODO and FIXME tags

2009-11-18 Thread Jean-Michel Pichavant
Scott David Daniels wrote: Martin P. Hellwig wrote: Ben Finney wrote: Chris Rebert writes: 2009/11/16 Yasser Almeida Hernández : How is the sintaxis for set the TODO and FIXME tags...? ... There's no widely-followed “syntax” for this convention, though. Except for _not_ doing what is sugg

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 1:32 am, Chris Rebert wrote: > On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell wrote: > > On the topic of "switch" statements and even-more-concise-then-we-have- > > already if/elif/else/end constructs, I have to say that Python does > > occasionally force you to write code like the code

Re: Stagnant Frame Data?

2009-11-18 Thread Mike
On Nov 15, 1:36 pm, Terry Reedy wrote: > Peter Otten wrote: > > Mike wrote: > > >> I'll apologize first for this somewhat lengthy example. It does > >> however recreate the problem I've run into. This is stripped-down code > >> from a much more meaningful system. > > >> I have two example classes,

Re: Stagnant Frame Data?

2009-11-18 Thread Mike
On Nov 15, 1:36 pm, Terry Reedy wrote: > Peter Otten wrote: > > Mike wrote: > > >> I'll apologize first for this somewhat lengthy example. It does > >> however recreate the problem I've run into. This is stripped-down code > >> from a much more meaningful system. > > >> I have two example classes,

PyQt4 4.4.4 : a bug with highlightBlock ?

2009-11-18 Thread Snouffy
Hello everybody, I've been trying to do some syntax highlighting using PyQt4. I ported the example given in the documentation of Qt4 to Python. It works fine on my computer at work (which has PyQt4 version 4.3.3) but doesn't on my home computer (which has version 4.4.4) : it gets stuck in an infin

getting properly one subprocess output

2009-11-18 Thread Jean-Michel Pichavant
Hi python fellows, I'm currently inspecting my Linux process list, trying to parse it in order to get one particular process (and kill it). I ran into an annoying issue: The stdout display is somehow truncated (maybe a terminal length issue, I don't know), breaking my parsing. import subproc

Re: ANN: Urwid 0.9.9 - Console UI Library

2009-11-18 Thread Daniel Fetchinson
>> How did you make the html 'screenshots'? I guess you have some kind of >> urwid2html tool or some such or is it plain ncurses? > > It's all handled in the demo code. This is from tour.py: > > if urwid.web_display.is_web_request(): > screen = urwid.web_display.Screen() > else: >

Re: Accessing a Web server --- how?

2009-11-18 Thread Nick Stinemates
This is what the History and Compare URL translates to: http://service.nordea.com/nordea-openpages/six.action?target=/nordea.public/bond/nordeabond.page&magic=(cc+(detail+(tsid+310746)+(view+hist)))& Some questions.. Do you have an idea on what the tsid is? It looks like it's a unique identifier

Re: A different take on finding primes

2009-11-18 Thread Nigel Rowe
On Tue, 17 Nov 2009 05:21, Tobiah wrote in comp.lang.python <>: > >>> Let me >>> be clear, given 2min, how many primes can you find, they need not be in >>> order or consecutive. > > Do they have to go from low to high? :( ) 1) google list of prime numbers 2) see "Prime numbers list" in the r

Re: Language mavens: Is there a programming with "if then else ENDIF"syntax?

2009-11-18 Thread bartc
Dotan Cohen wrote: 2009/11/16 Steve Ferg steve.ferg.bitbuc...@gmail.com: I've often thought that a language with this kind of block-free syntax would be nice and intuitive: if then do stuff elif then do stuff else do stuff endif Note that you do not need block delimiters. Does anybody k

Re: python simply not scaleable enough for google?

2009-11-18 Thread sturlamolden
On 18 Nov, 00:31, Terry Reedy wrote: > The > problem for the future is the switch to multiple cores for further speedups. The GIL is not a big problem for scientists. Scientists are not so dependent on threads as the Java/webdeveloper crowd: - We are used to running multiple processes with MPI.

Re: python simply not scaleable enough for google?

2009-11-18 Thread sturlamolden
On 18 Nov, 00:24, greg wrote: > NumPy, for example, is *extremely* flexible. Someone put > in the effort, once, to write it and make it fast -- and > now an endless variety of programs can be written very easily > in Python to make use of it. I'm quite sure David Cournapeau knows about NumPy...

break LABEL vs. exceptions + PROPOSAL

2009-11-18 Thread Lo'oris
I've found this email, back from 10 years ago: http://mail.python.org/pipermail/python-list/1999-September/009983.html I guess it went unnoticed, because that proposal looks really intresting. • break labels have been refused into python • we can do it anyway using exceptions • this is a proposal

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Simon Brunning
2009/11/17 sjm : > On Nov 16, 12:54 pm, Steve Ferg > wrote: > >> Does anybody know a language with this kind of syntax for >> ifThenElseEndif? > > Modern-day COBOL: > > IF      some-condition >        do-something > ELSE >        do-something-else > END-IF. RPG/400's SELEC statement: http://bit.

Re: break LABEL vs. exceptions + PROPOSAL

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 4:05 AM, Lo'oris wrote: > I've found this email, back from 10 years ago: > http://mail.python.org/pipermail/python-list/1999-September/009983.html > > I guess it went unnoticed, because that proposal looks really > intresting. > > • break labels have been refused into pytho

Re: ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread M.-A. Lemburg
Steve Howell wrote: > During the last few days I have written code in support of a small DDL > language that encapsulates a concise representation of the > manipulations needed to make a deep subcopy of a Python-like data > structure. It is inspired by syntax from mainstream modern languages, > inc

Minimally intrusive XML editing using Python

2009-11-18 Thread Thomas Lotze
I wonder what Python XML library is best for writing a program that makes small modifications to an XML file in a minimally intrusive way. By that I mean that information the program doesn't recognize is kept, as are comments and whitespace, the order of attributes and even whitespace around attrib

Re: Redirect stdout to a buffer [Errno 9]

2009-11-18 Thread Ecir Hana
On Nov 17, 6:51 am, "Gabriel Genellina" wrote: > > The code below now reads from the pipe everything that has been written --   > except from Python :( Thanks a lot for the fine code! So far I don't know why it fails to print from Python - I'll post here any news I get... -- http://mail.python.

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Stefan Behnel
Thomas Lotze, 18.11.2009 13:55: > I wonder what Python XML library is best for writing a program that makes > small modifications to an XML file in a minimally intrusive way. By that I > mean that information the program doesn't recognize is kept, as are > comments and whitespace, the order of attr

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 4:55 AM, Thomas Lotze wrote: > I wonder what Python XML library is best for writing a program that makes > small modifications to an XML file in a minimally intrusive way. By that I > mean that information the program doesn't recognize is kept, as are > comments and whitesp

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Thomas Lotze
Stefan Behnel wrote: > Take a look at canonical XML (C14N). In short, that's the only way to get a > predictable XML serialisation that can be used for textual diffs. It's > supported by lxml. Thank you for the pointer. IIUC, c14n is about changing an XML document so that its textual representati

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Thomas Lotze
Chris Rebert wrote: > Have you considered using an XML-specific diff tool such as: I'm afraid I'll have to fall back to using such a thing if I don't find a solution to what I actually want to do. I do realize that XML isn't primarily about its textual representation, so I guess I shouldn't be s

Re: ast manipulation

2009-11-18 Thread Tsize
Terry, Thank you for responding. I actually figured out how to do this shortly after posting the message. Sorry I wasn't quite clear enough in my post, I will try to be a little more explict in the future. Just to mention it I want to go to each node in the ast including child nodes and change t

Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-18 Thread Keith Hughitt
Hi all, I ran into a problem recently when trying to add support for earlier versions of Python (2.4 and 2.5) to some database related code which uses MySQLdb, and was wondering if anyone has any suggestions. With later versions of Python (2.6), inserting Unicode is very simple, e.g.: # -*-

Re: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-18 Thread Diez B. Roggisch
Keith Hughitt wrote: > Hi all, > > I ran into a problem recently when trying to add support for earlier > versions of Python (2.4 and 2.5) to some database related code which > uses MySQLdb, and was wondering if anyone has any suggestions. > > With later versions of Python (2.6), inserting Unico

base64MIME problem, Or Just New Email Client

2009-11-18 Thread Victor Subervi
Hi; I'm using SimpleMail, available from SF, that used to work fine for me but now I can't build it on my new server. I get this error: [Tue Nov 17 09:53:13 2009] [error] [client 208.84.198.58] import smtplib, referer: http://globalsolutionsgroup.vi/display_spreadsheet.py [Tue Nov 17 09:53:13

Re: open source linux -> windows database connectivity?

2009-11-18 Thread Tony Schmidt
Woo-hoo! Forget ODBC. Got this working with Jython and JDBC drivers! On Nov 13, 1:03 am, "M.-A. Lemburg" wrote: > TonySchmidtwrote: > >> Note: The client part of this product is free. You only need to > >> get a license for the server part. > > > Yeah, but don't I need the server part to make t

best performance for storage of server information for python CGI web app?

2009-11-18 Thread davidj411
I am wondering what will give me the best performance for storing information about the servers in our environment. currently i store all info about all servers in a single shelve file, but i have concerns. 1) as the size of the shelve file increases, will performance suffer ? 2) what about if 2 up

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Grant Edwards
On 2009-11-18, hong zhang wrote: >> Apparently the harddisk where you stored the file is full? It's not a real file, and takes up no space. > I have plenty space see: > $ df -l > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/sda1 74027808 4910016 65357

non-copy slices

2009-11-18 Thread tbourden
Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the end I wrote it myself but I was wond

Re: non-copy slices

2009-11-18 Thread Tim Golden
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the end I

Re: non-copy slices

2009-11-18 Thread tbourden
Ahhh yes! that's exactly it. Thanks for pointing out! Themis On Wed, Nov 18, 2009 at 3:44 PM, Tim Golden wrote: > tbour...@doc.ic.ac.uk wrote: > > Hi, > > > > I was looking for a facility similar to slices in python library that > would > > avoid the implicit creation of a new list and copy of

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 11:25 am, Jean-Michel Pichavant wrote: > Hi python fellows, > > I'm currently inspecting my Linux process list, trying to parse it in > order to get one particular process (and kill it). > I ran into an annoying issue: > The stdout display is somehow truncated (maybe a terminal length i

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 4:14 pm, Jon Clements wrote: > On Nov 18, 11:25 am, Jean-Michel Pichavant > wrote: > > > > > Hi python fellows, > > > I'm currently inspecting my Linux process list, trying to parse it in > > order to get one particular process (and kill it). > > I ran into an annoying issue: > > The s

using struct module on a file

2009-11-18 Thread Ulrich Eckhardt
Hia! I need to read a file containing packed "binary" data. For that, I find the struct module pretty convenient. What I always need to do is reading a chunk of data from the file (either using calcsize() or a struct.Struct instance) and then parsing it with unpack(). For that, I repeatedly wri

question about tree in python

2009-11-18 Thread nospam
How should I write a tree using diconary. I have used a dictonary to make a tree. tree={best:collections.defaultdict(lambda:default)} in a id3 tree. Is there a way to multple values and when then only return on type of values. I tried this apporach but it did not work. class Tree: def _

Re: Beautifulsoup code that is not running

2009-11-18 Thread Peter Pearson
On Tue, 17 Nov 2009 14:38:55 -0800 (PST), Zeynel wrote: [snip] from BeautifulSoup import BeautifulSoup > soup = BeautifulSoup (file("test.html").read()) title = soup.find('title') titleString = title.string open('extract.text', 'w').write(titleString) > > This runs without

Re: ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread Steve Howell
On Nov 18, 4:34 am, "M.-A. Lemburg" wrote: > Steve Howell wrote: > > [...] > > Here is an example of the DDL (and I hate the terminology "DDL," just > > cannot think of anything better): > > >             { > >                 'show_table_of_contents', > >                 'author' { > >          

Re: using struct module on a file

2009-11-18 Thread Jon Clements
On Nov 18, 4:42 pm, Ulrich Eckhardt wrote: > Hia! > > I need to read a file containing packed "binary" data. For that, I find the > struct module pretty convenient. What I always need to do is reading a chunk > of data from the file (either using calcsize() or a struct.Struct instance) > and then

Re: _winreg error on open key (64bit) - proper usage of _winreg.DisableReflectionKey

2009-11-18 Thread Brian Curtin
On Tue, Nov 17, 2009 at 19:59, Mark Hammond wrote: > On 18/11/2009 6:29 AM, Randall Walls wrote: > >> I don't believe so, but it seems like I'm in a catch 22, where I need to >> _winreg.OpenKey the key first before I can pass it to >> _winreg.DisableReflectionKey, but it doesn't exist, so I can't

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang
--- On Wed, 11/18/09, Grant Edwards wrote: > From: Grant Edwards > Subject: Re: IOError: [Errno 28] No space left on device > To: python-list@python.org > Date: Wednesday, November 18, 2009, 9:22 AM > On 2009-11-18, hong zhang > wrote: > > >> Apparently the harddisk where you stored the file

DOM related question and problem

2009-11-18 Thread elca
Hello, these day im making python script related with DOM. problem is these day many website structure is very complicate . what is best method to check DOM structure and path.. i mean...following is some example. what is best method to check can extract such like following info quickly? bef

Re: ANN: Urwid 0.9.9 - Console UI Library

2009-11-18 Thread Chris Jones
I noticed that when run on a 256-color capable xterm, upon exiting the demo programs the colors in the bash shell are modified - e.g the bash prompt, the output of colored ls commands. For instance, due to my fiddling with dircolors, a file with executable flags on is normally displayed in light

Re: DOM related question and problem

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 10:04 AM, elca wrote: > Hello, > these day im making python script related with DOM. > > problem is these day many website structure is very complicate . > > what is best method to check DOM structure and path.. > > i mean...following is some example. > > what is best metho

Re: break LABEL vs. exceptions + PROPOSAL

2009-11-18 Thread Terry Reedy
Chris Rebert wrote: On Wed, Nov 18, 2009 at 4:05 AM, Lo'oris wrote: I've found this email, back from 10 years ago: http://mail.python.org/pipermail/python-list/1999-September/009983.html I guess it went unnoticed, because that proposal looks really intresting. I think it went unnoticed becau

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Diez B. Roggisch
hong zhang wrote: > > > --- On Wed, 11/18/09, Grant Edwards wrote: > >> From: Grant Edwards >> Subject: Re: IOError: [Errno 28] No space left on device >> To: python-list@python.org >> Date: Wednesday, November 18, 2009, 9:22 AM >> On 2009-11-18, hong zhang >> wrote: >> >> >> Apparently the

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Anthra Norell
Thomas Lotze wrote: Chris Rebert wrote: Have you considered using an XML-specific diff tool such as: I'm afraid I'll have to fall back to using such a thing if I don't find a solution to what I actually want to do. I do realize that XML isn't primarily about its textual representatio

Re: Command line arguments??

2009-11-18 Thread Nobody
On Tue, 17 Nov 2009 23:57:55 +, Rhodri James wrote: >>> Quote the filenames or escape the spaces: >>> >>> C:\Python26\Python.exe C:\echo.py "C:\New Folder\text.txt" >>> >>> We've been living with this pain ever since windowed GUIs encouraged >>> users >>> to put spaces in their file names (A

Re: Calling Python functions from Excel

2009-11-18 Thread Cannonbiker
On 18 lis, 03:09, "Mark Tolonen" wrote: > "Chris Withers" wrote in message > > news:4b02d1e3.6080...@simplistix.co.uk... > > > Mark Tolonen wrote: > > Please I need Calling Python functions from Excel and receive result > back in Excel. Can me somebody advise simplest solution please? I

Re: getting properly one subprocess output

2009-11-18 Thread Nobody
On Wed, 18 Nov 2009 12:25:14 +0100, Jean-Michel Pichavant wrote: > I'm currently inspecting my Linux process list, trying to parse it in > order to get one particular process (and kill it). > I ran into an annoying issue: > The stdout display is somehow truncated (maybe a terminal length issue,

Re: non-copy slices

2009-11-18 Thread Terry Reedy
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the en

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang
--- On Wed, 11/18/09, Grant Edwards wrote: > From: Grant Edwards > Subject: Re: IOError: [Errno 28] No space left on device > To: python-list@python.org > Date: Wednesday, November 18, 2009, 9:22 AM > On 2009-11-18, hong zhang > wrote: > > >> Apparently the harddisk where you stored the file

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang
--- On Wed, 11/18/09, Diez B. Roggisch wrote: > From: Diez B. Roggisch > Subject: Re: IOError: [Errno 28] No space left on device > To: python-list@python.org > Date: Wednesday, November 18, 2009, 12:11 PM > hong zhang wrote: > > > > > > > --- On Wed, 11/18/09, Grant Edwards > wrote: > >

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Dave Angel
Thomas Lotze wrote: Chris Rebert wrote: Have you considered using an XML-specific diff tool such as: I'm afraid I'll have to fall back to using such a thing if I don't find a solution to what I actually want to do. I do realize that XML isn't primarily about its textual representatio

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Nobody
On Wed, 18 Nov 2009 13:55:52 +0100, Thomas Lotze wrote: > I wonder what Python XML library is best for writing a program that makes > small modifications to an XML file in a minimally intrusive way. By that I > mean that information the program doesn't recognize is kept, as are > comments and whit

Re: python gui builders

2009-11-18 Thread Dave Cook
On 2009-11-18, sturlamolden wrote: > GPL If it's an issue for your project, I suggest wxPython. It's cross-platform, fairly complete, and extensible. But the API is clunky compared to Qt. Dave Cook -- http://mail.python.org/mailman/listinfo/python-list

A Good Mailer

2009-11-18 Thread Victor Subervi
Hi; I need a good mailer that will enable me to mail email from web forms. Suggestions? TIA, Victor -- http://mail.python.org/mailman/listinfo/python-list

Re: WindowsError is not available on linux?

2009-11-18 Thread Aahz
In article , Peng Yu wrote: > >It's not clear to me whether WindowsError is available on linux or >not, after I read the document. Here's what I told a co-worker to do yesterday: if os.name == 'nt': DiskError = (OSError, WindowsError) else: DiskError = WindowsError try: disk_opera

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Grant Edwards
On 2009-11-18, Diez B. Roggisch wrote: > hong zhang wrote: >>> >>> > but following is good. >>> > >>> > cont_tx = 1 >>> > for i in >>> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'): >>> >with open(i, 'w') as f: >>> >print >>f, >>> cont_tx >>> >>> Well, if that works, th

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Simon Forman
On Wed, Nov 18, 2009 at 4:15 AM, Steve Howell wrote: > On the topic of "switch" statements and even-more-concise-then-we-have- > already if/elif/else/end constructs, I have to say that Python does > occasionally force you to write code like the code below.  Maybe > "force" is too strong a word, bu

Re: Language mavens: Is there a programming with "if then else ENDIF"syntax?

2009-11-18 Thread Dotan Cohen
> The OP explicitly said no block delimiters. Your example uses {..}, and > doesn't have endif. > Just out of habit. I think that PHP, like C, lets you avoid the block deliminators so long as the block all fits on one line. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http

Re: non-copy slices

2009-11-18 Thread Themis Bourdenas
Sth else that I noticed as I started using islice. The name is somewhat misleading. Having the slice part in the name I would expect it to imitate the functionality of normal slices. Random access, sub-slicing etc. However, it is only iteratable. Any particular reasons for that? My guess is that it

Re: WindowsError is not available on linux?

2009-11-18 Thread Benjamin Kaplan
On Wed, Nov 18, 2009 at 2:53 PM, Aahz wrote: > In article , > Peng Yu   wrote: >> >>It's not clear to me whether WindowsError is available on linux or >>not, after I read the document. > > Here's what I told a co-worker to do yesterday: > > if os.name == 'nt': >    DiskError = (OSError, WindowsErr

Using "setup.py" for an application, not a library module.

2009-11-18 Thread John Nagle
Most of the documentation for "setup.py" assumes you're packaging a library module. (Ref: "http://docs.python.org/distutils/setupscript.html";) How do you properly package an application? What happens on "setup.py install"? Where does the application get installed? Where does the main progr

Re: WindowsError is not available on linux?

2009-11-18 Thread exarkun
On 07:53 pm, a...@pythoncraft.com wrote: In article , Peng Yu wrote: It's not clear to me whether WindowsError is available on linux or not, after I read the document. Here's what I told a co-worker to do yesterday: if os.name == 'nt': DiskError = (OSError, WindowsError) else: DiskEr

Re: python gui builders

2009-11-18 Thread Simon Hibbs
On 18 Nov, 07:51, sturlamolden wrote: > > GPL PyQT is GPL for now, but Qt itself is available under the LGPL as is PySide. Eventualy PySide, which tracks the PyQT API, will supplant it and the issue will be moot. For now it can be a problem, but PyQT developer licenses are very afordable at only

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang
--- On Wed, 11/18/09, Grant Edwards wrote: > From: Grant Edwards > Subject: Re: IOError: [Errno 28] No space left on device > To: python-list@python.org > Date: Wednesday, November 18, 2009, 2:00 PM > On 2009-11-18, Diez B. Roggisch > > wrote: > > hong zhang wrote: > >>> > >>> > but followin

Re: WindowsError is not available on linux?

2009-11-18 Thread Christian Heimes
Dave Angel wrote: > Worse, even if the exception cannot be thrown on a non-Windows > environment, leaving it undefined makes it very awkward to write > portable code. An except clause that can never happen in a particular > environment is pretty innocent. Or somebody can use a base class for

Re: non-copy slices

2009-11-18 Thread Ethan Furman
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the en

Re: python gui builders

2009-11-18 Thread Simon Hibbs
On 17 Nov, 23:25, Kevin Walzer wrote: > On 11/17/09 4:25 PM, Tim Daneliuk wrote: > > > +1 Tkinter for the simple stuff > > You can actually use Tkinter to do quite sophisticated GUI's that rival > anything found in Qt or wx... Neither Tkinteror Wx have anything that come close to QGraphicsView, t

Re: python gui builders

2009-11-18 Thread David Bolen
Simon Hibbs writes: > I've had this problem for a few years. I've tried PythonCard, > WxWidgets with WxDesigner, BoaConstructor, etc. None of them come > anywhere close to PyQT/QTDesigner. For me, the killer feature missing from of all of the wx-based designers is that they require sizer based d

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2009 09:33:38 +0200, Dotan Cohen wrote: >> Is there any particular reason why this might be a *bad* language- >> design idea? > > It is about as far from OO as one could get. Whether or not that is > "bad" depends on the use case. That's crazy talk. IF...ENDIF is *syntax*, not a

Re: WindowsError is not available on linux?

2009-11-18 Thread Dave Angel
Benjamin Kaplan wrote: On Wed, Nov 18, 2009 at 2:53 PM, Aahz wrote: In article , Peng Yu wrote: It's not clear to me whether WindowsError is available on linux or not, after I read the document. Here's what I told a co-worker to do yesterday: if os.name ='nt': DiskError

Re: question about tree in python

2009-11-18 Thread Lie Ryan
nospam wrote: How should I write a tree using diconary. I have used a dictonary to make a tree. dictionary tree? root = { 'node_a': { 'node_a_a': 'blah', 'node_a_b': 'foo', 'node_a_c': 'bar', }, 'node_b': { 'node_b_a': 'soo', 'node_b_b': 'fle

Solved: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-18 Thread Threader Slash
-- Forwarded message -- From: Keith Hughitt To: python-list@python.org Date: Wed, 18 Nov 2009 06:09:11 -0800 (PST) Subject: Inserting Unicode text with MySQLdb in Python 2.4-2.5? Hi all, I ran into a problem recently when trying to add support for earlier versions of Python (2.4 a

Re: python gui builders

2009-11-18 Thread Stef Mientki
Simon Hibbs wrote: On 18 Nov, 07:51, sturlamolden wrote: GPL PyQT is GPL for now, but Qt itself is available under the LGPL as is PySide. Eventualy PySide, which tracks the PyQT API, will supplant it and the issue will be moot. For now it can be a problem, but PyQT developer licenses

Re: Using "setup.py" for an application, not a library module.

2009-11-18 Thread Philip Semanchuk
On Nov 18, 2009, at 3:53 PM, John Nagle wrote: Most of the documentation for "setup.py" assumes you're packaging a library module. (Ref: "http://docs.python.org/distutils/setupscript.html ") How do you properly package an application? What happens on "setup.py install"? Where does the ap

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2009 02:06:49 -0800, Steve Howell wrote: > P.S. The underscores before the method names might look a little funny > for inner methods, but it's the nature of the code..._dict and _list > would lead to confusion with builtins, if not actual conflict. Then name them something sensib

Re: A Good Mailer

2009-11-18 Thread Nick Stinemates
On Wed, Nov 18, 2009 at 03:27:11PM -0400, Victor Subervi wrote: > Hi; > I need a good mailer that will enable me to mail email from web forms. smtplib > Suggestions? silly example.. #!/usr/bin/env python import smtplib session = smtplib.SMTP("localhost") username = "abc" password = "def" sessi

Re: using struct module on a file

2009-11-18 Thread Simon Forman
On Wed, Nov 18, 2009 at 11:42 AM, Ulrich Eckhardt wrote: > Hia! > > I need to read a file containing packed "binary" data. For that, I find the > struct module pretty convenient. What I always need to do is reading a chunk > of data from the file (either using calcsize() or a struct.Struct instanc

Re: python gui builders

2009-11-18 Thread Kevin Walzer
On 11/18/09 4:15 PM, Simon Hibbs wrote: On 17 Nov, 23:25, Kevin Walzer wrote: On 11/17/09 4:25 PM, Tim Daneliuk wrote: +1 Tkinter for the simple stuff You can actually use Tkinter to do quite sophisticated GUI's that rival anything found in Qt or wx... Neither Tkinteror Wx have anything t

Re: Using "setup.py" for an application, not a library module.

2009-11-18 Thread Alan Franzoni
On 11/18/09 9:53 PM, John Nagle wrote: > Most of the documentation for "setup.py" assumes you're packaging a > library module. (Ref: "http://docs.python.org/distutils/setupscript.html";) > How do you properly package an application? What happens > on "setup.py install"? Where does the applica

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2009 01:53:50 -0800, Steve Howell wrote: > On Nov 18, 1:32 am, Chris Rebert wrote: >> On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell >> wrote: >> > On the topic of "switch" statements and >> > even-more-concise-then-we-have- already if/elif/else/end constructs, >> > I have to say t

Re: New syntax for blocks

2009-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2009 18:28:11 +1300, greg wrote: > r wrote: >> I think the syntax was chosen because the alternatives are even worse >> AND since assignment is SO common in programming, would you *really* >> rather type two chars instead of one? > > Smalltalk solved the problem by using a left-arr

Arcane question regarding white space, editors, and code collapsing

2009-11-18 Thread Wells
I work in TextMate a lot, which I generally love, but it's code collapsing confounds me. Essentially you have to indent blank lines to the proper level for the current block. Then it will collapse that section as one section. If you have simply a new line, it will see it as a break, and not collaps

Re: Arcane question regarding white space, editors, and code collapsing

2009-11-18 Thread Ben Finney
Wells writes: > Is it... pythonic, then, to have these lines of tabs/spaces to support > code collapsing? Is it proper, improper, or irrelevant? It's quite improper (though syntactically null, in Python) to have trailing whitespace on lines. That includes blank lines. One major reason is that t

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 2:22 pm, Steven D'Aprano wrote: > On Wed, 18 Nov 2009 02:06:49 -0800, Steve Howell wrote: > > P.S. The underscores before the method names might look a little funny > > for inner methods, but it's the nature of the code..._dict and _list > > would lead to confusion with builtins, if not

Writing a Carriage Return in Unicode

2009-11-18 Thread Doug
Hi! I am trying to write a UTF-8 file of UNICODE strings with a carriage return at the end of each line (code below). filOpen = codecs.open("c:\\temp\\unicode.txt",'w','utf-8') str1 = u'This is a test.' str2 = u'This is the second line.' str3 = u'This is the third line.' strCR = u"\u240D" fil

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 3:02 pm, Steven D'Aprano wrote: > > That depends on the code. In particular, it depends on how coupled the > code is. Ideally, you should have loosely coupled code, not highly > coupled. If the code is loosely coupled, then there's no problem with > understanding it in isolation. If the

Re: DOM related question and problem

2009-11-18 Thread elca
Chris Rebert-6 wrote: > > On Wed, Nov 18, 2009 at 10:04 AM, elca wrote: >> Hello, >> these day im making python script related with DOM. >> >> problem is these day many website structure is very complicate . >> >> what is best method to check DOM structure and path.. >> >> i mean...following i

combinatorics via __future__ generators

2009-11-18 Thread Phlip
Python: I have a quaint combinatorics problem. Before I solve it, or find a solution among "generators", I thought y'all might like to show off any solutions. Given an array like this... [0, 4, 3] Produce an array like this: [ [0, 0, 0], [0, 1, 0], [0, 2, 0], [0, 3, 0],

  1   2   >