mass editing for keys in a dictionary

2007-09-14 Thread james_027
hi, How could I transform something like this dict_1 = {'customer_id':1, 'item_id':3, amount:100} into dict_2 = {'customer':1, 'item':3, amount:100} thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: "once" assigment in Python

2007-09-14 Thread Steve Holden
Lorenzo Di Gregorio wrote: > Hello, > > I've been using Python for some DES simulations because we don't need > full C speed and it's so much faster for writing models. During > coding I find it handy to assign a variable *unless it has been > already assigned*: I've found that this is often refe

Re: Spaces from string specifier

2007-09-14 Thread Gabriel Genellina
En Fri, 14 Sep 2007 01:57:43 -0300, Gavin Tomlins <[EMAIL PROTECTED]> escribi�: > I'm trying to work out when using a format specifier I get spaces in the > resulting string. Eg. Looking at the outputted string you can see that > there are spaces after T5LAT, F4LAT etc. as I result from trying

Re: mass editing for keys in a dictionary

2007-09-14 Thread Amit Khemka
On 9/14/07, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > How could I transform something like this > > dict_1 = {'customer_id':1, 'item_id':3, amount:100} > > into > > dict_2 = {'customer':1, 'item':3, amount:100} A one liner would be : >>> dict_2 = dict([(k.split('_')[0], v) for (k,v) in dict_

funny little 190 lines command line math tutor I wrote for my 7-year old.

2007-09-14 Thread DouhetSukd
Sadly lacking in multi-media bells and whistles. But my daughter actually likes playing with it. Coded on windows, but no reason it shouldn't work on Linux/OS X. (hopefully the indentation won't be too mangled by usenet. apologies in advance if that is the case) Enjoy. Sample session: D:\use

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
On 14 Sep, 02:35, Jürgen Urner <[EMAIL PROTECTED]> wrote: > Puh, what a discussion... most common use case I can think of is > > >> d = {'a': 1, 'b': 2, 'c': 3} > >> for key in d: > >> # do something that relies on order of keys as specified in the > >> constructor > > It's a bit tireing havin

Re: Python 3K or Python 2.9?

2007-09-14 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Bruno Desthuilliers wrote: >> Bjoern Schliessmann a écrit : > >>> Why don't you make a preprocessor which accepts method >>> declarations without "self" and fixes them? >> The problem being that there's no such thing as a "method >> declaration" in Python > > Yep,

Re: funny little 190 lines command line math tutor I wrote for my 7-year old.

2007-09-14 Thread DouhetSukd
Ok, it does look a bit mangled. I re-posted it on www.pastebin.com, at http://python.pastebin.com/m7b1f9ab5. Cheers -- http://mail.python.org/mailman/listinfo/python-list

Re: mass editing for keys in a dictionary

2007-09-14 Thread Bruno Desthuilliers
james_027 a écrit : > hi, > > How could I transform something like this > > dict_1 = {'customer_id':1, 'item_id':3, amount:100} > > into > > dict_2 = {'customer':1, 'item':3, amount:100} dict_2 = dict((k[:-3], v) for k, v in dict_1.iteritems()) -- http://mail.python.org/mailman/listinfo/pytho

calculate matrik

2007-09-14 Thread susanti marsol
how to calculate the matrik? can u give me the sintax code? thanks so much before. - Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.-- http://mail.python.org/mailman/listinfo/python-list

Re: "once" assigment in Python

2007-09-14 Thread DouhetSukd
Agree that what you are looking for may not be a good idea. So make sure you don't shoot yourself in the foot with it. You should probably look into your problem some more. >>> def once(obj,attrname,value): ... if hasattr(obj,attrname): ... return ... else: ... se

Re: "once" assigment in Python

2007-09-14 Thread Peter Otten
Lorenzo Di Gregorio wrote: > I've been using Python for some DES simulations because we don't need > full C speed and it's so much faster for writing models. During > coding I find it handy to assign a variable *unless it has been > already assigned*: I've found that this is often referred to as

Re: "once" assigment in Python

2007-09-14 Thread Carl Banks
On Fri, 14 Sep 2007 06:16:56 +, Lorenzo Di Gregorio wrote: > Hello, > > I've been using Python for some DES simulations because we don't need > full C speed and it's so much faster for writing models. During coding > I find it handy to assign a variable *unless it has been already > assigned

Re: lxml + mod_python: cannot unmarshal code objects in restricted execution mode

2007-09-14 Thread Dmitri Fedoruk
On Sep 14, 3:04 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > Try forcing mod_python to run your code in the first interpreter > instance created by Python. > PythonInterpreter main_interpreter Thank you very much, that solved the problem! A more detailed discussion can also be found in the l

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
I forgot one item in the proposed API: ordereddict.delete(index : int) Also, the API for keys() should be ordereddict.keys(firstindex : int = None, secondindex : int = None) If called with no args, returns list of all keys (in key order of course); if one arg is given, returns keys with indexes

Just bought Python in a Nutshell

2007-09-14 Thread Lamonte Harris
http://www.powells.com/biblio/63-9780596001889-7 Used, has anyone read this book. Any additional information that you like,dislike about this book? [I like having real books and stead of ebooks because its better on the eyes.] Should be her 2morrow Afternoon :), few hours before I get home great

Re: newbie: self.member syntax seems /really/ annoying

2007-09-14 Thread Bjoern Schliessmann
stef mientki wrote: > Indeed, so I wondered why there isn't open source alternative (at > least I didn't find one). Have a look at scilab and octave. Not sure if it's GPL though. Regards, Björn -- BOFH excuse #387: Your computer's union contract is set to expire at midnight. -- http://mail

Re: extract text from log file using re

2007-09-14 Thread Peter Otten
Fabian Braennstroem wrote: > I would like to delete a region on a log file which has this > kind of structure: > > > #--flutest >498 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 > 8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499 >

Re: Python 3K or Python 2.9?

2007-09-14 Thread Bjoern Schliessmann
Bruno Desthuilliers wrote: > A method is a thin wrapper around a function, usually instanciated > and returned by the __get__ method [1] of the function itself when > the function is looked up as an attribute of a class or an > instance: > [...] That's interesting, thank you for the explanation.

Re: Python 3K or Python 2.9?

2007-09-14 Thread Bjoern Schliessmann
Terry Reedy wrote: > No it does not. The method wrapping is done at runtine. The > compiler is ignorant of the wrapping that will be done. Agreed, after reading the docs. dis.dis(f) > 1 0 LOAD_GLOBAL 0 (c) > 3 LOAD_ATTR1 (meth) >

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Antoon Pardon
On 2007-09-14, Mark Summerfield <[EMAIL PROTECTED]> wrote: > On 14 Sep, 02:35, Jürgen Urner <[EMAIL PROTECTED]> wrote: >> Puh, what a discussion... most common use case I can think of is >> >> >> d = {'a': 1, 'b': 2, 'c': 3} >> >> for key in d: >> >> # do something that relies on order of keys

smtp debugging methods

2007-09-14 Thread Sean Nakasone
I'm having trouble with sending smtp mail. It's hanging after the smtplib.SMTP() line. It doesn't works from home but not from work. What's the best way to debug this? # Here's my script import smtplib msg = "Subject: Hello\n\nThis is the\nbody of the message." server = smtplib.SMTP("smtp.gmai

Re: smtp debugging methods

2007-09-14 Thread Jon Ribbens
On 2007-09-14, Sean Nakasone <[EMAIL PROTECTED]> wrote: > I'm having trouble with sending smtp mail. It's hanging after the > smtplib.SMTP() line. It doesn't works from home but not from work. What's > the best way to debug this? > > # Here's the error server = smtplib.SMTP("smtp.gmail.com

Re: smtp debugging methods

2007-09-14 Thread Tim Williams
On 14/09/2007, Sean Nakasone <[EMAIL PROTECTED]> wrote: > I'm having trouble with sending smtp mail. It's hanging after the > smtplib.SMTP() line. It doesn't works from home but not from work. What's > the best way to debug this? > > # Here's my script > import smtplib > msg = "Subject: Hello\n\n

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
On 14 Sep, 10:49, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2007-09-14, Mark Summerfield <[EMAIL PROTECTED]> wrote: > > > > > On 14 Sep, 02:35, Jürgen Urner <[EMAIL PROTECTED]> wrote: > >> Puh, what a discussion... most common use case I can think of is > > >> >> d = {'a': 1, 'b': 2, 'c': 3} >

Re: recursion

2007-09-14 Thread Gigs_
sorry i think that i express wrong. having problem with english what i mean is how python knows to add all thing at the end of recursion >>> def f(l): if l == []: return [] else: return f(l[1:]) + l[:1] f([1,2,3]) recursion1 f([2,3]) + [1] recursion2 f([3]) +

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Antoon Pardon
On 2007-09-14, Mark Summerfield <[EMAIL PROTECTED]> wrote: > On 14 Sep, 10:49, Antoon Pardon <[EMAIL PROTECTED]> wrote: >> > # some time later >> > d["e"] = 15 >> > # later still >> > d["b"] = 70 >> > d.keys() # returns ['a', 'b', 'e', 'm', 'x'] >> > d.values() # returns [1, 70, 15, 4, 20] >> >> wh

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote: > sorry i think that i express wrong. having problem with english > > > what i mean is how python knows to add all thing at the end of recursion Because you have written code that tells Python to do so. ;-) > >>> def f(l): > if l == []: >

Re: Python 3K or Python 2.9?

2007-09-14 Thread Duncan Booth
Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> Ben Finney <[EMAIL PROTECTED]> (BF) wrote: > >>BF> The latter two statements are equivalent. The >>'instance.method(args)' BF> syntax is just sugar for >>'Class.method(instance, args)'. > > It is more than just syntactic sugar because the Class

Install Mac OS X - Idle doesn't show up

2007-09-14 Thread Dominique
Hello, Sorry bothering you with such a trivial problem. I installed python on a new mac at office. It seems everything is fine: in the console, I access to python. But I just can't start Idle. It seems to open but closes immediately (it appears in the dock and closes immediately). It is also impo

Re: recursion

2007-09-14 Thread Steve Holden
Gigs_ wrote: > sorry i think that i express wrong. having problem with english > > > what i mean is how python knows to add all thing at the end of recursion > > >>> def f(l): > if l == []: > return [] > else: > return f(l[1:]) + l[:1] > > > f([1,2,3]) > > recursi

Re: recursion

2007-09-14 Thread John Machin
On Sep 14, 10:04 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote: > > sorry i think that i express wrong. having problem with english > > > what i mean is how python knows to add all thing at the end of recursion > > Because you have written

Re: Install Mac OS X - Idle doesn't show up

2007-09-14 Thread Dominique
Dominique gmail.com> writes: > > One precision: When I go in the console and type idle, it works: idle appears. But I would like to be able to launch idle from the dock Dominique -- http://mail.python.org/mailman/listinfo/python-list

Re: "once" assigment in Python

2007-09-14 Thread Lorenzo Di Gregorio
Thank you very much for your suggestions! I'll try in the next days to elaborate a bit on the last two ones. By the way, the "once" assignment is not that evil if you use it for hardware modeling. Most hardware models look like: wire1 = function() instance component(input=wire1,output=wire2) resu

Re: extract text from log file using re

2007-09-14 Thread Paul McGuire
On Sep 13, 4:09 pm, Fabian Braennstroem <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to delete a region on a log file which has this > kind of structure: > How about just searching for what you want. Here are two approaches, one using pyparsing, one using the batteries-included re module. -

Re: How to Start

2007-09-14 Thread Shawn Milochik
On 9/14/07, James Stroud <[EMAIL PROTECTED]> wrote: > > Here's your recipe: > >1. begin coding until you hit a wall >2. read official tutorial until you figure out a solution >3. experiment in interactive interpreter >4. goto 1. > > I know this sounds obvious, but its the best way t

Re: Install Mac OS X - Idle doesn't show up

2007-09-14 Thread Kevin Walzer
Dominique wrote: > Hello, > > Sorry bothering you with such a trivial problem. > > I installed python on a new mac at office. > It seems everything is fine: in the console, I access to python. > But I just can't start Idle. It seems to open but closes immediately (it > appears > in the dock and

Re: [Tutor] Just bought Python in a Nutshell

2007-09-14 Thread Shawn Milochik
My best advice: Skim it -- just flip the pages, glancing at each one without really reading it -- maybe just read the bold type. You'll find that very rewarding when you run into a problem in your coding and remember that you saw *something* which could be related. You will probably notice some bu

Re: [Tutor] list iteration question for writing to a file on disk

2007-09-14 Thread Shawn Milochik
When you use "print," it automatically adds a newline (\n). You can avoid this by following the print line with a comma: print j, Or rstrip() the line before printing. Either way. -- http://mail.python.org/mailman/listinfo/python-list

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
On 14 Sep, 12:46, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2007-09-14, Mark Summerfield <[EMAIL PROTECTED]> wrote: > > > > > On 14 Sep, 10:49, Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> > # some time later > >> > d["e"] = 15 > >> > # later still > >> > d["b"] = 70 > >> > d.keys() # returns

Re: recursion

2007-09-14 Thread Gigs_
Steve Holden wrote: > Gigs_ wrote: >> sorry i think that i express wrong. having problem with english >> >> >> what i mean is how python knows to add all thing at the end of recursion >> >> >>> def f(l): >> if l == []: >> return [] >> else: >> return f(l[1:]) + l[:1] >>

where is help file?

2007-09-14 Thread PaulS
new to Fedora7, typed python in interactive interpreter, then help(). Then modules to get a list of modules. Then module name to get info on a module but no help file. What is the help file name? Is there an environmental variable I have to set? Thanks, Paul -- http://mail.python.org/ma

Re: recursion

2007-09-14 Thread J. Clifford Dyer
On Fri, Sep 14, 2007 at 01:40:17PM +0200, Gigs_ wrote regarding Re: recursion: > > what i mean is how python knows to add all thing at the end of recursion > > >>> def f(l): > if l == []: > return [] > else: > return f(l[1:]) + l[:1] > The following script does exa

Re: where is help file?

2007-09-14 Thread Carsten Haese
On Fri, 2007-09-14 at 10:00 -0400, PaulS wrote: > new to Fedora7, typed python in interactive interpreter, then help(). Then > modules to get a list of modules. Then module name to get info on a module > but no help file. What is the help file name? Is there an environmental > variable I hav

Re: recursion

2007-09-14 Thread Neil Cerutti
On 2007-09-14, John Machin <[EMAIL PROTECTED]> wrote: > On Sep 14, 10:04 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote: >> > sorry i think that i express wrong. having problem with english >> >> > what i mean is how python knows to add al

Re: Install Mac OS X - Idle doesn't show up

2007-09-14 Thread Dominique
Kevin Walzer codebykevin.com> writes: > > > > How did you install/build Python? On the Mac, you really aren't supposed > to start it from the terminal unless you are running it under X11 or are > using a non-framework build. If you built it the standard Mac way, or if > you use the binary in

newbee: Simple Backend Python Script Question

2007-09-14 Thread joe shoemaker
I need to create python script that is threaded. So the main program will run in infinite loop and just retrieving messages and putting them in a queue. (Main thread) I need child threads from a pool to process the queue. When there is no stuff in the queue, they go to the pool and become availabl

subclass of integers

2007-09-14 Thread Mark Morss
I would like to construct a class that includes both the integers and None. I desire that if x and y are elements of this class, and both are integers, then arithmetic operations between them, such as x+y, return the same result as integer addition. However if either x or y is None, these operati

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
On Fri, 14 Sep 2007 15:58:39 +0200, Gigs_ wrote: > >>> def factorial(n): > print "n =", n > if n==0: > return 1 > else: > return n * factorial(n-1) > > >>> factorial(3) > n = 3 > n = 2 > n = 1 > n = 0 > 6 > > > now i understand. but one question at the end this fun

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Antoon Pardon
On 2007-09-14, Mark Summerfield <[EMAIL PROTECTED]> wrote: >> > Also, it does not provide the key(), value(), and item() methods that >> > the API I proposed can support (because in an ordereddict, index >> > positions make sense). >> >> At the time I wrote my module I never had a need for these. D

RE: How to Start

2007-09-14 Thread Sells, Fred
I like eclipse+pydev; although I did pay my dues learning the basics of eclipse. F9 saves file and runs it. If you're an emacs dude, emacs + python mode is pretty good. ctrl-c ctrl-c runs the active buffer. Of course if you don't already know emacs, avoid it like the plague. > -Original Mes

Re: recursion

2007-09-14 Thread Steve Holden
Gigs_ wrote: > Steve Holden wrote: [...] >> >> regards >> Steve > >>> def factorial(n): > print "n =", n > if n==0: > return 1 > else: > return n * factorial(n-1) > > >>> factorial(3) > n = 3 > n = 2 > n = 1 > n = 0 > 6 > > > now i understand. but one question at t

Re: subclass of integers

2007-09-14 Thread Mark Morss
On Sep 14, 10:30 am, Mark Morss <[EMAIL PROTECTED]> wrote: > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as

Re: subclass of integers

2007-09-14 Thread Zentrader
I would do something along the lines of the following, although it only tests for integers and not floats, so would return 'None' for a float. class Nint(int): def __add__(self, x, y): if isinstance(x, int) and isinstance(y, int): return x+y return None if __name__

Re: subclass of integers

2007-09-14 Thread Zentrader
This would accept ints, floats, and decimal types. import decimal class Nint(int): def __add__(self, x, y): try: return x+y except: return None if __name__=='__main__': N=Nint() print N.__add__( 1, 2 ) print N.__add__( 1, None ) print N

Re: automatic parallelization

2007-09-14 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Mikhail Teterin <[EMAIL PROTECTED]> wrote: . . . >> I'm fond of Linda > http://www.unixreview.com/documents/s=10125/ur0704l/ >, Parallel >> Python http://www.parallelpython.com/ > only one of s

Re: newbee: Simple Backend Python Script Question

2007-09-14 Thread Steve Holden
joe shoemaker wrote: > I need to create python script that is threaded. So the main program > will run in infinite loop and just retrieving messages and putting them > in a queue. (Main thread) > > I need child threads from a pool to process the queue. When there is no > stuff in the queue, the

Re: "once" assigment in Python

2007-09-14 Thread Alex Martelli
Lorenzo Di Gregorio <[EMAIL PROTECTED]> wrote: > When employing Python it's pretty straightforward to translate the > instance to an object. > > instance = Component(input=wire1,output=wire2) > > Then you don't use "instance" *almost* anymore: it's an object which > gets registered with the simu

Re: Just bought Python in a Nutshell

2007-09-14 Thread DouhetSukd
I respectfully disagree with Shawn, in this case. Don't skim Nutshell, unless you know very little Python, and even then it is really the wrong book. It is rather dry reading and provides very little of the usual user-friendly introductions to language features by solving simple problems. Doesn'

Re: How to Start

2007-09-14 Thread DouhetSukd
On Sep 13, 4:02 pm, Nikita the Spider <[EMAIL PROTECTED]> wrote: > My $.02 for someone such as yourself > is to deal with Python and as little else as possible. So write your > code in a simple text editor like UltraEdit or Notepad Second that opinion. Use _your_ favorite basic text editor and ru

Re: where is help file?

2007-09-14 Thread Martin Blume
"Carsten Haese" schrieb > > new to Fedora7, typed python in interactive interpreter, then help(). > > Then modules to get a list of modules. Then module name to get info > > on a module but no help file. What is the help file name? > > Is there an environmental variable I have to set? > > There i

Re: where is help file?

2007-09-14 Thread Carsten Haese
On Fri, 2007-09-14 at 18:20 +0200, Martin Blume wrote: > AFAIK you have to import the module first, before you can get help > on that module. While that is true of the help(module_name) form, this is not necessary in the interactive helper you start by calling help(). -- Carsten Haese http://inf

Re: Python 3K or Python 2.9?

2007-09-14 Thread Terry Reedy
"Bjoern Schliessmann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] That's interesting. BTW, do you know something (apart from the dis docs) that's worth reading if you're interested in Python byte code? -- That is the only Python specific thing I remember reading.

Re: where is help file?

2007-09-14 Thread Neil Cerutti
On 2007-09-14, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-09-14 at 18:20 +0200, Martin Blume wrote: >> AFAIK you have to import the module first, before you can get >> help on that module. > > While that is true of the help(module_name) form, this is not > necessary in the interactive

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
On 14 Sep, 15:35, Antoon Pardon <[EMAIL PROTECTED]> wrote: [snip] > I wish you all the luck you can get. Maybe if you succeed I'll change > my mind about writing a PEP myself. > > However I think your chances will increase if you write your module > and have it available in the cheese shop. If peop

Re: recursion

2007-09-14 Thread Terry Reedy
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |f([1, 2, 3]) | r1 f([2, 3]) + [1] | r2 f([3]) + [2] + [1] | r3 f([]) + [3] + [2] + [1] | r4 [] + [3] + [2] + [1] I might help to note that the above is effectively parenthesized ( ( ([]+{3]) + [2]) +

Re: subclass of integers

2007-09-14 Thread Michael Spencer
Mark Morss wrote: > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as integer addition. However if either x o

Re: Coming from Perl - SOLVED

2007-09-14 Thread I V
On Thu, 13 Sep 2007 23:49:32 -0400, Amer Neely wrote: > In trying to track down why this script would not run on my host, it has > to come to light that Python is installed, however the Apache module is > not. So, short story is - I was flogging a dead horse. Which Apache module? You don't need an

Re: subclass of integers

2007-09-14 Thread Bruno Desthuilliers
Zentrader a écrit : > This would accept ints, floats, and decimal types. It doesn't... > import decimal Useless > class Nint(int): > def __add__(self, x, y): The prototype for __add__ is __add__(self, other) > try: > return x+y > except: > return No

Rename multiple files using names in a text file

2007-09-14 Thread rémi
Hi, I would like to rename files (jpg's ones) using a text file containing the new names... Below is the code that doesn't work : * #!/usr/bin/python #-*- coding: utf-8 -*- from os import listdir, getcwd, rename import re list_names=['new_name1','new_name2'] list_files = listdir(getcwd()) filt

Re: subclass of integers

2007-09-14 Thread Bruno Desthuilliers
Mark Morss a écrit : > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as integer addition. However if either

Re: An ordered dictionary for the Python library?

2007-09-14 Thread James Stroud
Mark Summerfield wrote: > So to clarify, here's the entire API I'm proposing for ordereddict. In > all cases the ordereddict is always in (and kept in) key order, and > any method that returns a list or iterator always returns that list or > iterator (whether of keys or values) in key order: > > o

Re: Rename multiple files using names in a text file

2007-09-14 Thread James Stroud
rémi wrote: > Hi, > > I would like to rename files (jpg's ones) using a text file containing the > new names... > Below is the code that doesn't work : > * > #!/usr/bin/python > #-*- coding: utf-8 -*- > from os import listdir, getcwd, rename > import re > list_names=['new_name1','new_name2'] >

Https conversation - debug?

2007-09-14 Thread Johny
Is there any good sniffer for https protocol? How can be watched https conversation? Thanks for reply L. -- http://mail.python.org/mailman/listinfo/python-list

Re: Https conversation - debug?

2007-09-14 Thread Jarek Zgoda
Johny napisał(a): > Is there any good sniffer for https protocol? > How can be watched https conversation? Any packet sniffer will do. Then you have to decrypt the stream. ;) -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: An ordered dictionary for the Python library?

2007-09-14 Thread Mark Summerfield
On 14 Sep, 20:25, James Stroud <[EMAIL PROTECTED]> wrote: > Mark Summerfield wrote: [snip] > May I also make one more suggestion, to call it a "sort_ordered_dict" > (or "sortordereddict", or even better a "sorteddict"--where the "ed" > comes from "ordered")? Its hard for me to move past the establi

Re: Just bought Python in a Nutshell

2007-09-14 Thread Lamonte Harris
Right, I like reading books it comes handier then reading ebooks, less programs and its right there in your hands. Main reason I'm going to use it for is to find questions without asking them on the python list or tutor list for a quicker referrence. On 9/14/07, [EMAIL PROTECTED] <[EMAIL PROTECT

why does Configparser change names to lowercase ?

2007-09-14 Thread stef mientki
hello, Why does Configparser change names to lowercase ? As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase thanks, Stef Mientki

Re: An ordered dictionary for the Python library?

2007-09-14 Thread James Stroud
Mark Summerfield wrote: > I guess I'll have to rename my module (although unfortunately, my book > has just gone into production and I have a (simpler) example of what I > considered to be an ordered dict, so I will be adding to the > terminology confusion). That notwithstanding, given that it is a

Re: How to Start

2007-09-14 Thread James Stroud
Paul McGuire wrote: > Do "neophytes" just dive in and try stuff? I think a lot of us coming from other fields actually slithered in, in true python style. -- http://mail.python.org/mailman/listinfo/python-list

Re: why does Configparser change names to lowercase ?

2007-09-14 Thread James Stroud
stef mientki wrote: > hello, > > Why does Configparser change names to lowercase ? Because it is an annoying module and should be tossed for something better? Try this instead (and never look back): http://www.voidspace.org.uk/python/configobj.html > As Python is case sensitive (which btw

Make money to share your videos

2007-09-14 Thread earnloads007
Goodtolove.com is sharing their 50% adsense revenue with you to post videos of anything. Just keep up logging in and start posting now to make money... -- http://mail.python.org/mailman/listinfo/python-list

Re: subclass of integers

2007-09-14 Thread Ian Clark
Mark Morss wrote: > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as integer addition. However if either x o

regexp search on infinite string?

2007-09-14 Thread Paddy
Lets say i have a generator running that generates successive characters of a 'string' >From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive charac

Re: 2 daemons write to a single file /w python file IO

2007-09-14 Thread Steven W. Orr
On Tuesday, Sep 11th 2007 at 21:17 -0700, quoth Andrey: =>i have a newbie question about the file() function. =>I have 2 daemons running on my linux box. => =>1 will record the IDs to a file - logs.txt =>other 1 will open this file, read the IDs, and then "Clean up the =>file" -logs.txt => =>Sin

Re: why does Configparser change names to lowercase ?

2007-09-14 Thread Rob Wolfe
stef mientki <[EMAIL PROTECTED]> writes: > hello, > > Why does Configparser change names to lowercase ? > > As Python is case sensitive (which btw I don't like at all ;-) > but now when really need the casesensitivity, > because it handles about names which should be recognized by human, > it cha

Re: Just bought Python in a Nutshell

2007-09-14 Thread Danyelle Gragsone
Luckily that site still had one left .. so i brought it :D. I can always use another good and CHEAP book. Danyelle -- http://mail.python.org/mailman/listinfo/python-list

Re: where is help file?

2007-09-14 Thread PaulS
Thanks everyone. Paul "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2007-09-14, Carsten Haese <[EMAIL PROTECTED]> wrote: >> On Fri, 2007-09-14 at 18:20 +0200, Martin Blume wrote: >>> AFAIK you have to import the module first, before you can get >>> help on that

Re: Python 3K or Python 2.9?

2007-09-14 Thread John Roth
On Sep 12, 11:35 am, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > On Sep 12, 4:40 am, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > > Ivan Voras wrote: > > > What does "self" have to do with an object model? It's an > > > function/method argument that might as well be hidden in the > > > compi

Re: recursion

2007-09-14 Thread John Machin
On Sep 15, 3:06 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > There have been languages, for instance, Fortran IV, where local variables > were part of the function 'object' and which therefore prohibited recursion > because of the very problem you alluded to in your question. (My guess is > th

reading xls file from python

2007-09-14 Thread hassen62
hi friends, I have installed python 2.5 for windows in my pc, I have a file xls say "file.xls" in c:/python25. How I can read this files from Python. Many thanks in advance. Hassen.-- http://mail.python.org/mailman/listinfo/python-list

Re: subclass of integers

2007-09-14 Thread Ian Clark
Ian Clark wrote: > Mark Morss wrote: >> I would like to construct a class that includes both the integers and >> None. I desire that if x and y are elements of this class, and both >> are integers, then arithmetic operations between them, such as x+y, >> return the same result as integer addition.

Re: Spaces from string specifier

2007-09-14 Thread Ian Clark
Gabriel Genellina wrote: > En Fri, 14 Sep 2007 01:57:43 -0300, Gavin Tomlins <[EMAIL PROTECTED]> > escribi�: > >> I'm trying to work out when using a format specifier I get spaces in the >> resulting string. Eg. Looking at the outputted string you can see that >> there are spaces after T5LAT,

Re: Python 3K or Python 2.9?

2007-09-14 Thread George Sakkis
On Sep 12, 1:35 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > On Sep 12, 4:40 am, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > > Ivan Voras wrote: > > > What does "self" have to do with an object model? It's an > > > function/method argument that might as well be hidden in the > > > compi

Re: List Comprehension Question: One to Many Mapping?

2007-09-14 Thread beginner
On Aug 24, 5:35 am, Boris Borcic <[EMAIL PROTECTED]> wrote: > Paul Rubin wrote: > > beginner <[EMAIL PROTECTED]> writes: > >> For example, if I have x=[ [1,2], [3,4] ] > > >> What I want is a new list of list that has four sub-lists: > > >> [[1,2], [f(1), f(2)], [3,4], [f(3), f(4)]] > > > [[a, map(

Re: subclass of integers

2007-09-14 Thread Dan Bishop
On Sep 14, 9:30 am, Mark Morss <[EMAIL PROTECTED]> wrote: > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as

Re: Extended slicing and Ellipsis - where are they used?

2007-09-14 Thread James Stroud
Paddy wrote: > And the ellipses ... ? ;) py> class Bob(dict): ... def __getitem__(self, k, *args, **kwargs): ... if k is Ellipsis: ... return sorted(self.keys()) ... else: ... return dict.__getitem__(self, k, *args, **kwargs) ... def __setitem__(self, k, *args, **kwargs):

Is there some sort of Python Error log.

2007-09-14 Thread Lamonte Harris
Command prompt is a pain and it would be pretty nice to have this feature. -- http://mail.python.org/mailman/listinfo/python-list

Re: Car-ac-systems

2007-09-14 Thread Arne Vajhøj
[text reordered from top post to standard newsgroup style] John Timney (MVP) wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Sep 11, 9:35 am, "John Timney \(MVP\)" >> <[EMAIL PROTECTED]> wrote: >>> How do I control one with C# then! Thats not on your site, clearly no

Re: Https conversation - debug?

2007-09-14 Thread Bjoern Schliessmann
Johny wrote: > Is there any good sniffer for https protocol? Yes. > How can be watched https conversation? As a matter of principle, with every working sniffer. I'd use wireshark's "follow TCP stream" function. Regards, Björn -- BOFH excuse #198: Post-it Note Sludge leaked into the monito

  1   2   >