Re: making 'utf-8' default codec

2006-02-27 Thread Scott David Daniels
Nikola Skoric wrote: > Is there a way of making 'utf-8' default codec for the whole program, so > I don't have to do .encode('utf-8') every time I print out a string? Explicit is better than implicit (so setting up a default codec is considered bad practice). However, you could wrap an output de

Re: Using ElementTree to tidy up an XML string to my liking

2006-02-27 Thread Magnus Lycka
Richard Townsend wrote: > On Fri, 24 Feb 2006 18:21:59 +0100, Magnus Lycka wrote: >>Concerning element names, it's your coice of course, but I agree >>more and more with Guido and PEP008 that camelCase is ugly. (Not >>that ALLCAPS is better...) > > I can see in PEP008 where it says Capitalized_Wor

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Dan Sommers
On Mon, 27 Feb 2006 03:13:08 -0600, Tim Chase <[EMAIL PROTECTED]> wrote: > Same could go for days of the week: dow=enum(("sunday", 0), ("monday", 1), > ("start_of_work_week", 1), ... ("friday", 5), > ("end_of_work_week", 5)...) Not really: In some parts of the world, calendar weeks begin

Re: spaces at ends of filenames or directory names on Win32

2006-02-27 Thread rtilley
[EMAIL PROTECTED] wrote: > Please post your Python code. I don't see the problem you're > describing. OK, here's a copy. This works on Mac/Unix/Linux yet has no effect on Windows: - import os import os.path for root, dirs, files

Re: spaces at ends of filenames or directory names on Win32

2006-02-27 Thread rtilley
[EMAIL PROTECTED] wrote: > Please post your Python code. I don't see the problem you're > describing. OK, here's a copy. This works on Mac/Unix/Linux yet has no effect on Windows: - import os import os.path for root, dirs, files

Waiting for Connection

2006-02-27 Thread D
I am trying to do the following using Python and Tkinter: 1) Display a window with 1 button 2) When user clicks the button, Python attempts to call a function that opens a socket and listens for a connection - what I want to do is, if the socket has been successfully opened and the system is wai

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Eric Nieuwland
On 27 feb 2006, at 10:13, Tim Chase wrote: >> Uniqueness imposes an odd constraint that you can't have >> synonyms in the set: >> > shades = enum({white:100, grey:50, gray:50, black:0}) > > Blast, I hate responding to my own posts, but as soon as I > hit Send, I noticed the syntax here was bif

PEP 354 -- "in" operator?

2006-02-27 Thread Roy Smith
If I have an enum, how can I verify that it's a legal value? Can I do: Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat') def foo (day): if day not in Weekdays: raise ValueError Also, do enums have __dict__ slots? Can I do something like: day = 'sun' print Weekdays.__d

Re: Use of __slots__

2006-02-27 Thread Alex Martelli
Don Taylor <[EMAIL PROTECTED]> wrote: ... > Does Python have the notion of static class attributes? No. > Just what was going on when I redefined my __slots__ attribute? Nothing. > It looks as if __slots__ is something really special, or I am managing Yep: it acts at *class-creation time*,

Re: how do I factor a number down to one digit?

2006-02-27 Thread johnzenger
Your tools are: 1. "map" lets you apply a function to every element of a list. Strings are lists. (List comprehensions let you do the same thing, but "map" is better to use if you are turning in homework). 2. "sum" lets you calculate the sum of all numbers in a list. 3. "val" and "str" let you

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > But if you have a good usage case for an empty enum, > please feel free to tell us. I could see empty enums being useful in machine-generated code, perhaps when generating wrappers around C library APIs. There might

Re: Best python module for Oracle, but portable to other RDBMSes

2006-02-27 Thread dananrg
How about DBdesigner4 or Dia as free ER diagrammers? [EMAIL PROTECTED] wrote: > Thanks Olivier and Jonathan. > > Do either of you, or anyone else, know of a good open source data > modeling / ER-diagram / CASE tools? I'd like to be able to build > relatively simple schemas in one open source too

Re: sort one list using the values from another list

2006-02-27 Thread Magnus Lycka
Dolmans Sun wrote: > Kent Johnson wrote: >> >>> [a for b,a in sorted(zip(B,A))] > > also, [a for _,a in sorted(zip(B,A))] > > didn't read refs, tested above python-2.2.3. Is there something here I can't see, or did you just change a variable name and present that as another solution? -- http:

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Tim Chase
> Uniqueness imposes an odd constraint that you can't have > synonyms in the set: > > >>> shades = enum({white:100, grey:50, gray:50, black:0}) Blast, I hate responding to my own posts, but as soon as I hit Send, I noticed the syntax here was biffed. Should have been something like >>> sha

Re: ImportError in Unpickle

2006-02-27 Thread [EMAIL PROTECTED]
It is indeed the problem. Thanks. May be, this fact could have been mentioned in the documentation. I have suggested the change using bug tracker. Raghu. -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of __slots__

2006-02-27 Thread Don Taylor
Steve Juranich wrote: > I might be a little confused about a couple of things (I'm sure many will > correct me if I'm not), but as I understand it the __slots__ attribute is a > class-attribute, which means it cannot be modified by an instance of the > class (think of a "static" class member, if y

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Tim Chase
Just a couple thoughts: > An enumeration is an exclusive set of symbolic names bound > to arbitrary unique values. Uniqueness imposes an odd constraint that you can't have synonyms in the set: >>> shades = enum({white:100, grey:50, gray:50, black:0}) Not a bad thing, as it would then have i

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Claudio Grondi
[EMAIL PROTECTED] wrote: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C > Just copy/paste the following source code to a file and run it: sourceCodeToExecute = """ dict1 = { 1:23,2:76,

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Tim Chase
>>Why are empty enumerations not allowed? Empty sets, empty lists, >>empty dictionaries are all allowed. I don't see any obvious benefits >>to not allowing empty enumerations. > > What is an empty enum? How and when would you use it? It's a Zen thing :) (agh! not the zen thread!) >>> roundS

Re: Python Indentation Problems

2006-02-27 Thread [EMAIL PROTECTED]
As far as i know, gedit is the weak link, this is because of the way it handles its whitespaces, had that trouble myself though not this *severe* -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Antoon Pardon
Op 2006-02-27, [EMAIL PROTECTED] schreef <[EMAIL PROTECTED]>: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C Well how about the straight forward: dict3 = {} for key, value in dict1.iteritems()

Re: wxPython: help(wx) causes segfaulting?

2006-02-27 Thread Franz Steinhaeusler
On 27 Feb 2006 04:55:15 -0800, "André" <[EMAIL PROTECTED]> wrote: > >Franz Steinhaeusler wrote: >> On Sun, 26 Feb 2006 10:35:13 -0600, Tim Chase >> <[EMAIL PROTECTED]> wrote: >> >> >Trying to get my feet wet with wxPython (moving from just >> >command-line apps), I tried the obvious (or, at least

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Tim Chase
> Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C >>> d1={1:23,2:76,4:56} >>> d2={23:"a", 76:"b", 56:"c"} >>> result = dict([(d1k,d2[d1v]) for (d1k, d1v) in d1.items()]) >>> result {1: 'a', 2

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C > >>> dict1 = {1:23, 2:76, 4:56} >>> dict2 = {23:'A', 76:'B', 56:'C'} >>> dict((key, dict2[value]) for key, val

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C > >>> dict1 = {1:23,2:76,4:56} >>> dict2 = {23:'A',76:'B',56:'C'} >>> dict((k, dict2[v]) for k, v in dict1.items()) {

How to do an 'inner join' with dictionaries

2006-02-27 Thread cyborg4
Let's say I have two dictionaries: dict1 is 1:23, 2:76, 4:56 dict2 is 23:A, 76:B, 56:C How do I get a dictionary that is 1:A, 2:B, 4:C -- http://mail.python.org/mailman/listinfo/python-list

Py2Exe - how to set BDist (Build) directory ?

2006-02-27 Thread Durumdara
Hi ! I want to set the temp. build directory that it is does not placed in python source directory. I want to set this: \bin\ compiled version \src\ python source \tmp\ temp build dir How to I do it ? Thanx for help: dd -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython: help(wx) causes segfaulting?

2006-02-27 Thread André
Franz Steinhaeusler wrote: > On Sun, 26 Feb 2006 10:35:13 -0600, Tim Chase > <[EMAIL PROTECTED]> wrote: > > >Trying to get my feet wet with wxPython (moving from just > >command-line apps), I tried the obvious (or, at least to me > >was obvious): > > > >Start python, "import wx" and then do a "hel

Re: making 'utf-8' default codec

2006-02-27 Thread Jarek Zgoda
Nikola Skoric napisał(a): > Is there a way of making 'utf-8' default codec for the whole program, so > I don't have to do .encode('utf-8') every time I print out a string? Bad idea. You may accidentally break some libraries that depend on ASCII being default & standard. -- Jarek Zgoda http://j

Re: how do I factor a number down to one digit?

2006-02-27 Thread bearophileHUGS
>Sounds like homework to me. Sorry Steven, you may be right, next time I'll be more careful. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Hiding a column at the root of a plone site ...

2006-02-27 Thread bruno at modulix
Paul Ertz wrote: > Hello, > > We would like to hide the left column for the main/home page of our > plone sites dynamically using a tal: expression. Then please post on a Zope/Plone related mailing-list. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]

wxPython and Py2Exe... 2 questions

2006-02-27 Thread Durumdara
Hi ! I have an application that I compile to exe. 1.) I want to compile main.ico into exe, or int zip. Can I do it ? 2.) Can I compile the result to my specified directory, not into the dist ? I want to structure my projects like this: \src\ python codes, etc. \res\ icons, etc \bin\ the compiled

making 'utf-8' default codec

2006-02-27 Thread Nikola Skoric
Hi there, Is there a way of making 'utf-8' default codec for the whole program, so I don't have to do .encode('utf-8') every time I print out a string? -- "Now the storm has passed over me I'm left to drift on a dead calm sea And watch her forever through the cracks in the beams Nailed across t

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Antoon Pardon
Op 2006-02-27, Steven D'Aprano schreef <[EMAIL PROTECTED]>: > Paul Rubin wrote: > >> Ben Finney <[EMAIL PROTECTED]> writes: >> >>>Enumerations with no values are meaningless. The exception >>>``EnumEmptyError`` is raised if the constructor is called with no >>>value arguments. >> >> >> Why are

Re: including directories with py2exe

2006-02-27 Thread Larry Bates
Mr BigSmoke wrote: > Hi All > how do i include directories into my project when using py2exe? I have > a module that has it's images directory and when it's searches it (into > ../dist/library.zip/.../mymodule/) it generates an error because the > directory wasn't imported... > tnx > > Fabio > Yo

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > All of the machinery of the enum class created by Ben Finney is just to > make sure that red, green and blue behave correctly, without extraneous > string-like or number-like methods. Of course Ben could modify his code so > that enum() returned an obje

Help getting started with Pycurl / libcurl ?

2006-02-27 Thread gjzusenet
Hi I just couldn't google up any docs or tutorial on how to set up everything necessary to use pycurl on windows. When I try running the pycurl setup I get a 'CURL_DIR' not found error, but no where can I find a detailed explanation of what is this dir, what dlls I need to install and where etc.

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Felipe Almeida Lessa <[EMAIL PROTECTED]> writes: > > If enums aren't supposed to work in that construction then the PEP > > shouldn't specify that they work that way. > > Sorry, but where do they say that? The PEP gives an example of iterating through the members of an enum. I'm not sure if that

Re: TypeError when subclassing 'list'

2006-02-27 Thread Gerard Flanagan
Simon Percivall wrote: > The error you're seeing is because you've rebound 'list' to something > else. Try putting "list = type([])" somewhere above your code. That's it! I had rebound 'list' earlier (in error), and though I deleted the code it must have been "remembered" somehow. Restarting Pyt

Re: TypeError when subclassing 'list'

2006-02-27 Thread looping
Gerard Flanagan wrote: > Hello all > > Could anyone shed any light on the following Exception? The code which > caused it is below. Uncommenting the 'super' call in 'XmlNode' gives > the same error. If I make XmlNode a subclass of 'object' rather than > 'list' then the code will run. > > Thanks in

minimize a program into an icon on the taskbar.

2006-02-27 Thread Rajesh Sathyamoorthy
Hi, I would know how to minimize a program (wxpython app) into an icon on the taskbar on windows (the one at the side near the clock, i can't remember what is it called.) Is it easy to be done? Is there a way to do the same thing on Linux? Thank You. -- http://mail.python.org/mailman/

Re: how do I factor a number down to one digit?

2006-02-27 Thread Steven D'Aprano
On Mon, 27 Feb 2006 02:31:42 -0800, Allan wrote: > I'm trying to write a numerology program where I have each letter > identified by a numerical value like > a=1 > b=2 > c=3 > as so forth. I then input a name. How do I treat each letter as a > single value? That is, instead of print myname I have

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Steven D'Aprano
On Mon, 27 Feb 2006 00:43:45 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> What is an empty enum? > > An empty enum is an enum with no identifiers, just like an empty list > is a list with no elements. No, I don't think that is the case. A list is a container. You ca

Re: how do I factor a number down to one digit?

2006-02-27 Thread bearophileHUGS
Allan>I hope this isn't too stupid of a question. It's a simple problem, but it's not a stupid question, this is a possible solution: data = "myname" radix = str(sum(ord(c)-96 for c in data)) while len(radix) > 1: radix = str(sum(int(c) for c in radix)) print "The radix of:\n", data, "\n\nIs:

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Felipe Almeida Lessa
Em Seg, 2006-02-27 às 02:42 -0800, Paul Rubin escreveu: > Felipe Almeida Lessa <[EMAIL PROTECTED]> writes: > > IMHO, you should be using sets, not enums. Something like: > > If enums aren't supposed to work in that construction then the PEP > shouldn't specify that they work that way. Sorry, but

Re: sort one list using the values from another list

2006-02-27 Thread Dolmans Sun
Kent Johnson wrote: > >>> [a for b,a in sorted(zip(B,A))] also, [a for _,a in sorted(zip(B,A))] didn't read refs, tested above python-2.2.3. -- Sun Yi Ming you can logout any time you like, but you can never leave... -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Felipe Almeida Lessa <[EMAIL PROTECTED]> writes: > > print_members('shorter:', months_shorter_than_february) > > print_members('longer:', months_longer_than_february) > > IMHO, you should be using sets, not enums. Something like: If enums aren't supposed to work in that construction then

Re: Reading from socket file handle took too long

2006-02-27 Thread Ben Sizer
Etienne Desautels wrote: > Everything works well but one thing. My problem is that running > nextFrame() took, most of the time, more then 0,0414 sec. so my video > is lagging. I monitor every call and I found that the culprit is when I > read from the socket file handle. It's the only bottleneck i

how do I factor a number down to one digit?

2006-02-27 Thread Allan
I'm trying to write a numerology program where I have each letter identified by a numerical value like a=1 b=2 c=3 as so forth. I then input a name. How do I treat each letter as a single value? That is, instead of print myname I have to do a print m+y+n+a+m+e which returns a number. I next want to

Re: sort one list using the values from another list

2006-02-27 Thread Ron Adam
Ron Adam wrote: > Alex Martelli wrote: >> Ron Adam <[EMAIL PROTECTED]> wrote: >>... >>> Considering the number time I sort keys after getting them, It's the >>> behavior I would prefer. Maybe a more dependable dict.sortedkeys() >>> method would be nice. ;-) >> >> sorted(d) is guaranteed to

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Felipe Almeida Lessa
Em Seg, 2006-02-27 às 00:43 -0800, Paul Rubin escreveu: > def print_members(header, e): # print header, then members of enum e > print header > for m in e: > print '\t', str(m) > > months_longer_than_february = enum('jan', 'mar', 'apr', ) # etc > months_shorter_tha

Re: wxPython: help(wx) causes segfaulting?

2006-02-27 Thread Franz Steinhaeusler
On Sun, 26 Feb 2006 10:35:13 -0600, Tim Chase <[EMAIL PROTECTED]> wrote: >Trying to get my feet wet with wxPython (moving from just >command-line apps), I tried the obvious (or, at least to me >was obvious): > >Start python, "import wx" and then do a "help(wx)" to see >what it can tell me. I

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-27 Thread Franz Steinhaeusler
On 24 Feb 2006 14:12:05 + (GMT), Sion Arrowsmith <[EMAIL PROTECTED]> wrote: >Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >>On Thu, 23 Feb 2006 13:54:50 +, Martin Franklin >>>why not use string methods strip, rstrip and lstrip >>because this removes only the last spaces, >> [given r = '

Re: Modifying body of select message in a 'mbox' file.

2006-02-27 Thread Cowmix
Well.. I hate to reply to my own post.. but here is an update.. When I flatten a 'mbox' mail message and suck it into a 'email' mail message.. things look fine except that every MIME encoded section has a 'UNIX From' header added to the top of it and the From user is set to 'nobody'.. Does an

Re: cx_Oracle and UTF8

2006-02-27 Thread Harald Armin Massa
Gerhard, thanks, that import os os.environ["NLS_LANG"] = "German_Germany.UTF8" import cx_Oracle con = cx_Oracle.connect("me/[EMAIL PROTECTED]") really helped. At least now the query returns something encoded differently. I dared not to believe that there is no "direct encoding change api" withou

Re: Using repr() with escape sequences

2006-02-27 Thread nummertolv
myString = "bar\foo\12foobar" print repr(myString) My "problem" was that I wanted to know if there is a way of printing "unraw" strings like myString so that the escape characters are written like a backslash and a letter or number. My understanding was that repr() did this and it does in most cas

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: Steven D'Aprano <[EMAIL PROTECTED]> writes: > What is an empty enum? An empty enum is an enum with no identifiers, just like an empty list is a list with no elements. > How and when would you use it? > The best I can come up with is that an empty enum

Callback

2006-02-27 Thread Ramkumar Nagabhushanam
Hello All, I am writing an application in C/C++ (VC++ 6.0 compiler) within which I want to make calls using the python FTP client (ftplib). I want to call (for example) after the necessary iniialization has been done: PyObject *t = PyObject_CallMethod (_FTP, "retrlines", , "LIST", c_functio

Re: ls files --> list packer

2006-02-27 Thread kpp9c
nice! two little lines that do a boatload of work! hee hee pth = '/Users/kpp9c/snd/01' samples = [os.path.join(pth, f) for f in os.listdir(pth) if f.endswith('.aif')] thank you Kent! (and Jeremy and Magnus and Singletoned and I V ... and john boy and mary ellen .. ) -- http://mail.pyt

Re: Is Python a Zen language?

2006-02-27 Thread none
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Kay Schluehr <[EMAIL PROTECTED]> wrote: > . > . > . > >>Lucid in the mid 80s that gone down a few years later. As it turned out >>that time Lisp was not capable to survive in

<    1   2