Re: python bijection

2009-11-20 Thread Joshua Bronson
On Nov 20, 3:09 pm, Terry Reedy wrote: > Use standard subscripting with slices, and only that, to both get and set. i did this for __delitem__ too, so you can do e.g. del m[:'abc']. > In fact, to emphasize the symmetry of the bijective map, consider > disallowing m[key] as ambiguous and require

Re: python simply not scaleable enough for google?

2009-11-20 Thread sturlamolden
On 20 Nov, 22:45, a...@pythoncraft.com (Aahz) wrote: > Are you advocating a high-fiber diet? Only if you are a ruminant. No really... Windows has user-space threads natively. But you must reserve some stack space for them (from virtual memory), which mainly makes them useful on 64 bit systems.

Re: python simply not scaleable enough for google?

2009-11-20 Thread Aaron Watters
> Because `language is slow' is meaningless. Yes. Everyone knows java is faster than Python right? But look here: http://gaejava.appspot.com/ (you might want to run it a couple times to see what it does when it is 'warm'). I don't think this is a biased test -- I think the author expected to

Re: python and web pages

2009-11-20 Thread Daniel Dalton
On Thu, Nov 19, 2009 at 09:43:50AM +0100, Diez B. Roggisch wrote: > >elinks, links, links2 and do the following. > >1. Open a certain web page and find the first text box on the page, and > >put this text into the form. > >2. Press the submit button, and wait for the result page to load. > >3. Clic

Re: Go versus Brand X

2009-11-20 Thread Mensanator
On Nov 20, 7:12 pm, a...@pythoncraft.com (Aahz) wrote: > Comparing Go to another computer language -- do you recognize it? No, it predates my entry into the computer biz. > > http://www.cowlark.com/2009-11-15-go/ > -- > Aahz (a...@pythoncraft.com)           <*>        http://www.pythoncraft.com/

Re: What is the naming convention for accessor of a 'private' variable?

2009-11-20 Thread Gregory Ewing
Steven D'Aprano wrote: On Wed, 18 Nov 2009 18:47:34 -0800, Chris Rebert wrote: Accessor methods are not Pythonic. Accessor methods are *usually* not Pythonic, at least not the way they are commonly used in Java. To elaborate, accessor methods that *only* read and write another, ordinary at

Go versus Brand X

2009-11-20 Thread Aahz
Comparing Go to another computer language -- do you recognize it? http://www.cowlark.com/2009-11-15-go/ -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverl

Re: Relative versus absolute paths on Windows

2009-11-20 Thread Gregory Ewing
Jason R. Coombs wrote: In other words, paths without a drive letter are reported as absolute, but treated as relative, except in a few special cases. It's not clear what the result ought to be here, since Windows drive-relative paths don't really fit into the unix absolute/relative dichotomy.

Re: semantics of [:]

2009-11-20 Thread Esmail
Diez B. Roggisch wrote: Esmail schrieb: None of your operations changes a. But I talked about the lists you bound b and c to before. Those aren't changed as well - they simply are not pointed to anymore. In your example, that means the will be garbage-collected, in other scenarios, such as th

Re: semantics of [:]

2009-11-20 Thread Diez B. Roggisch
Esmail schrieb: Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent ###

Re: semantics of [:]

2009-11-20 Thread Ethan Furman
Dave Angel wrote: Esmail wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent Semi-aside, if I wanted to make local copy of a li

Re: python bijection

2009-11-20 Thread Joshua Bronson
On Nov 20, 3:09 pm, Terry Reedy wrote: > Joshua Bronson wrote: > > Anyone have any other feedback? For instance, is offering the __call__ > > syntax for the inverse mapping wonderful or terrible, or maybe both? > > Terrible ;-) > > Use standard subscripting with slices, and only that, to both get

Re: python simply not scaleable enough for google?

2009-11-20 Thread Aahz
In article , sturlamolden wrote: > >Also note that Windows has native support for "taskelets", regardless >of language. They are called "fibers" (as opposed to "threads") and are >created using the CreateFiber system call. I would not be surprised if >Unix'es has this as well. We do not need Stac

RE: Gray Hat Python: Python Programming for Hackers Soft copy

2009-11-20 Thread Matt Mitchell
You mean like: http://nostarch.com/ghpython.htm From: python-list-bounces+mmitchell=transparent@python.org [mailto:python-list-bounces+mmitchell=transparent@python.org] On Behalf Of Elf Scripter Sent: Friday, November 20, 2009 3:31 PM To: python-list@python.org Subject: Gray Hat Python

Re: semantics of [:]

2009-11-20 Thread Esmail
Thank you all for your posts - this was very enlightening and I printed this thread off for future reference. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is an interactive command a block?

2009-11-20 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 20 Nov 2009 08:02:38 -0800, Ethan Furman wrote: module scope == global scope That is, there is nothing higher than module scope. (So, yes, global is a slight misnomer... in Python it means 'global to a module'.) Actually there is: built-ins. That's why you ca

Re: Relative versus absolute paths on Windows

2009-11-20 Thread Ethan Furman
Jason R. Coombs wrote: The current implementation of Python (2.6.4, 3.1.1) treats \bar as a relative path but reports it as an absolute path. ntpath.isabs('\\bar') True ntpath.abspath('\\bar') 'C:\\bar' os.chdir('d:\\') ntpath.abspath('\\bar') 'd:\\bar' os.chdir('server\\share'

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Steven D'Aprano
On Fri, 20 Nov 2009 03:08:01 -0800, DreiJane wrote: > NB: I wondered about about dict(one=1, two=2) - why not d = {one:1, > two:2} ? Because it doesn't work unless you have defined names one and two. dict(one=1, two=2) uses keyword arguments, namely one and two. This is the same standard mecha

Re: Is an interactive command a block?

2009-11-20 Thread Steven D'Aprano
On Fri, 20 Nov 2009 08:02:38 -0800, Ethan Furman wrote: >> Thanks, but hey, contradiction: you mention globals as an "enclosing" >> scope, i.e. that a module can have a scope, while stating that only >> classes and functions have their own scope (so, would a module have >> it's not own scope?). >

Re: No duplicate variable

2009-11-20 Thread Terry Reedy
King wrote: class A(object): def __init__(self, value=0.): self.value = value class B(A): def __init__(self, value=None): A.__init__(self) self.value = value obj = B() When "B" initializes, it overwrite "value" variable of "A". How do I make sure that no variabl

Gray Hat Python: Python Programming for Hackers Soft copy

2009-11-20 Thread Elf Scripter
Hi i`m looking for a place to get a soft copy of 'Gray Hat Python: Python Programming for Hackers' may be a pdf or chm format. Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Split class across multiple files

2009-11-20 Thread Terry Reedy
eric.frederich wrote: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like

Re: semantics of [:]

2009-11-20 Thread Duncan Booth
Dave Angel wrote: > > > Esmail wrote: >> Diez B. >> Roggisch wrote: >>> Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but

Re: python bijection

2009-11-20 Thread Terry Reedy
Joshua Bronson wrote: Anyone have any other feedback? For instance, is offering the __call__ syntax for the inverse mapping wonderful or terrible, or maybe both? Terrible ;-) Use standard subscripting with slices, and only that, to both get and set. Let m[4] == m[4:] == 'abc' # m[4:] is sugg

Re: sort values from dictionary of dictionaries python 2.4

2009-11-20 Thread J Wolfe
On Nov 9, 2:27 pm, Peter Otten <__pete...@web.de> wrote: > J Wolfe wrote: > > I would like to sort this dictionary by the values of the inner > > dictionary ‘ob’ key. > > Python's built-in dictionary is unsorted by design. > > > > > mydict = > > {’WILW1′: {’fx’: ‘8.1′, ‘obtime’: ‘2009-11-07 06:45:0

Re: Newsgroup for beginners

2009-11-20 Thread Ethan Furman
Aahz wrote: In article , Grant Edwards wrote: You've really got to try pretty hard to create one. But if you want to, here's how to do it: 1) Start by complaining that your program doesn't work because of a bug in Python. [...] Post of the month! I'll second that! I really needed a

Re: Does turtle graphics have the wrong associations?

2009-11-20 Thread Terry Reedy
Robert Maas, http://tinyurl.com/uh3t wrote: My proposed no-syntax IDE *also* gets rid of the need to bother with any programming-language syntax. I've been proposing it for years, but nobody has shown any interest What you describe below is similar to various systems that have been proposed an

Re: semantics of [:]

2009-11-20 Thread Dave Angel
Esmail wrote: Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > Semi-aside, if I wanted to make loc

Re: semantics of [:]

2009-11-20 Thread Stephen Hansen
> > The original list 'a', isn't changed in any of these cases right? And > modifying b, c or d would not change 'a' either - or am I not understanding > this correctly? > > ## 1 ## > > creates a new list and copies all elements from a to b > > Yes. > ## 2 ## > > take an already existing list (em

Re: Split class across multiple files

2009-11-20 Thread eric.frederich
Yeah... it does seem like a God Object. My reasoning for putting them all into one big class is that the class has references to all the required resources, connections, and services. The other option would be to have a simple object called Session which did nothing but login and hold those referen

Re: semantics of [:]

2009-11-20 Thread Luis Zarrabeitia
On Friday 20 November 2009 11:15:55 am Esmail wrote: > Could someone help confirm/clarify the semantics of the [:] operator > in Python? In short, a[:], when "a" is a list, returns a slice ("sublist") of "a" that happens to contain all the elemnts of "a". In general, a[low:upper:step] will give

Re: Too Many Values To Unpack

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > Now what I don't understand about the above code, provided by Dennis Lee > Bieber, is the "expand" statement. It's not a statement. It's a function. The function is defined in your code. Or rather, it's defined in the code that you copied from Dennis Lee Bieber, apparently.

Re: semantics of [:]

2009-11-20 Thread Esmail
Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent # 2

Re: PyQt4 4.4.4 : a bug with highlightBlock ?

2009-11-20 Thread Snouffy
> You need to change the indexOf() calls to indexIn() calls on the QRegExp > object: > >   index = expression.indexIn(text, index + length) Thank you so much ! After looking a bit more I found out that when using indexOf the command : length = expression.matchedLength() was the one causing a p

Re: python simply not scaleable enough for google?

2009-11-20 Thread sturlamolden
On 20 Nov, 11:12, Robin Becker wrote: > Presumably that means they could potentially run in parallel on the 10 cpu > machines of the future. > > I'm not so clear on whether the threadless tasklets will run on separate cpus. You can make a user-space scheduler and run a 10 tasklets on a t

Re: Python Will Not Send Email!!

2009-11-20 Thread Victor Subervi
On Fri, Nov 20, 2009 at 12:38 PM, Carsten Haese wrote: > Thank you. This proves conclusively that there IS in fact a file called > email.pyc (and/or email.py) in your directory next to testMail.py. It is > this email.pyc that is being imported instead of the email.py from the > Python library. Get

Re: semantics of [:]

2009-11-20 Thread Dave Angel
Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent # 2 #

Re: semantics of [:]

2009-11-20 Thread Tim Chase
Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent # 2 #

Re: Too Many Values To Unpack

2009-11-20 Thread Victor Subervi
On Fri, Nov 20, 2009 at 12:14 PM, Shashank Singh < shashank.sunny.si...@gmail.com> wrote: > Are you sure your key values are 2-tuples in levelDict? > No. Here's some tweaked code: cursor.execute('select category from categories order by category') theTree = expand(cursor.fetchall())

Re: Python Will Not Send Email!!

2009-11-20 Thread Kev Dwyer
On Fri, 20 Nov 2009 11:58:00 -0400, Victor Subervi wrote: Hello Victor, Carsten's well-specified instruction has identified your problem. >[r...@13gems globalsolutionsgroup.vi]# python -c "import email; print >email" > There is a file named email.pyc, most likely in your current directory, th

Newbie question about scrapy tutorial

2009-11-20 Thread Zeynel
Hello, I have a question about scrapy tutorial and I put 2 questions in the scrapy group http://groups.google.com/group/scrapy-users/t/d5afae7d88672e02 http://groups.google.com/group/scrapy-users/t/4d52fa8c589a412a but there were no answers. Can anyone here help me? The spider works fine but I c

Re: No duplicate variable

2009-11-20 Thread Diez B. Roggisch
King schrieb: class A(object): def __init__(self, value=0.): self.value = value class B(A): def __init__(self, value=None): A.__init__(self) self.value = value obj = B() When "B" initializes, it overwrite "value" variable of "A". How do I make sure that no varia

No duplicate variable

2009-11-20 Thread King
class A(object): def __init__(self, value=0.): self.value = value class B(A): def __init__(self, value=None): A.__init__(self) self.value = value obj = B() When "B" initializes, it overwrite "value" variable of "A". How do I make sure that no variable should not b

Re: Split class across multiple files

2009-11-20 Thread Carl Banks
On Nov 20, 8:14 am, "eric.frederich" wrote: > I have a class which holds a connection to a server and a bunch of > services. > In this class I have methods that need to work with that connection > and services. > > Right now there are about 50 methods some of which can be quite long. > From an org

Re: Python Will Not Send Email!!

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > On Fri, Nov 20, 2009 at 11:14 AM, Carsten Haese > wrote: > Please show us a copy-and-paste of your command line window contents > that result from executing <> and then executing > <> immediately thereafter. > > > [r...@13gems

Re: Split class across multiple files

2009-11-20 Thread Diez B. Roggisch
eric.frederich schrieb: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like

Re: Too Many Values To Unpack

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > Hi; > At one point Dennis Lee Bieber helped me with the following slightly > modified code: > > [snippage...] > > def getChildren(levelDict, level = 0): > MAXLEVEL = 7 > if level > MAXLEVEL: > return #possibly the data has a cycle/loop > for (nm, dt) in levelDict:

Re: semantics of [:]

2009-11-20 Thread Diez B. Roggisch
Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent # 2 ## c = [] c =

semantics of [:]

2009-11-20 Thread Esmail
Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent # The following two are equivalent # 2 ## c = [] c = a[:] # c receives a c

Serve Pages Under Different Ownership

2009-11-20 Thread Victor Subervi
Hi; I'm building a new server after many years hiatus. I currently can only serve python pages chown'd to root. How do I change this? TIA, Victor -- http://mail.python.org/mailman/listinfo/python-list

Re: Too Many Values To Unpack

2009-11-20 Thread Shashank Singh
On Fri, Nov 20, 2009 at 9:15 PM, Victor Subervi wrote: > Hi; > At one point Dennis Lee Bieber helped me with the following slightly > modified code: > > #!/usr/bin/python > > import sys,os > sys.path.append(os.getcwd()) > import MySQLdb > from login import login > import re, string > > def printTr

Split class across multiple files

2009-11-20 Thread eric.frederich
I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. >From an organizational standpoint, I'd like to have method implement

Re: python gui builders

2009-11-20 Thread sturlamolden
On 18 Nov, 22:18, David Bolen wrote: > With that said, for various reasons I still prefer wxPython to Qt, and > at the moment, find wxFormBuilder the best fit for my own designs > (even before the direct Python support, just using XRC). Personally I prefer wxFormBuilder over QtDesigner for sizer

Re: Regexp and multiple groups (with repeats)

2009-11-20 Thread Mark Tolonen
"mk" wrote in message news:he60ha$iv...@ger.gmane.org... Hello, >>> r=re.compile(r'(?:[a-zA-Z]:)([\\/]\w+)+') >>> r.search(r'c:/tmp/spam/eggs').groups() ('/eggs',) Obviously, I would like to capture all groups: ('/tmp', '/spam', '/eggs') But it seems that re captures only the last group. Is

Re: Is an interactive command a block?

2009-11-20 Thread Ethan Furman
Alf P. Steinbach wrote: * Benjamin Kaplan: On Thu, Nov 19, 2009 at 4:42 PM, Alf P. Steinbach wrote: >>> I feel that there's still something lacking in my understanding though, like how/where the "really actually just pure local not also global" is defined for function definition, but it's n

Re: Python Will Not Send Email!!

2009-11-20 Thread Victor Subervi
On Fri, Nov 20, 2009 at 11:14 AM, Carsten Haese wrote: > Kevin neglected to mention that the new interpreter session must be > started in the same directory as the one you're in when you run your > testMail.py script. Since he didn't mention that, we can't be sure that > that's what you did, so th

Re: Regexp and multiple groups (with repeats)

2009-11-20 Thread Neil Cerutti
On 2009-11-20, mk wrote: > Hello, > > >>> r=re.compile(r'(?:[a-zA-Z]:)([\\/]\w+)+') > > >>> r.search(r'c:/tmp/spam/eggs').groups() > ('/eggs',) > > Obviously, I would like to capture all groups: > ('/tmp', '/spam', '/eggs') You'll have to do something else, for example: >>> s = re.compile(r'(?:[

Re: Python Will Not Send Email!!

2009-11-20 Thread Victor Subervi
On Fri, Nov 20, 2009 at 11:05 AM, Kev Dwyer wrote: > I ran your script on a CentOS vm (5.2 server 32bit, not quite the same as > yours but also running python 2.4.3). It ran without error. So I > suspect that either you have a rogue email module/package on your machine > or there's something wr

Too Many Values To Unpack

2009-11-20 Thread Victor Subervi
Hi; At one point Dennis Lee Bieber helped me with the following slightly modified code: #!/usr/bin/python import sys,os sys.path.append(os.getcwd()) import MySQLdb from login import login import re, string def printTree(aTree, level=0): tree = [] for name in sorted(aTree.keys()): tree.ap

Re: Is an interactive command a block?

2009-11-20 Thread Alf P. Steinbach
* Benjamin Kaplan: On Thu, Nov 19, 2009 at 4:42 PM, Alf P. Steinbach wrote: * Steven D'Aprano: I feel that there's still something lacking in my understanding though, like how/where the "really actually just pure local not also global" is defined for function definition, but it's now just a va

Re: Python Will Not Send Email!!

2009-11-20 Thread Carsten Haese
Victor Subervi wrote: > On Thu, Nov 19, 2009 at 5:01 PM, Kev Dwyer > wrote: > > On Thu, 19 Nov 2009 11:28:37 -0400, Victor Subervi wrote: > > Hello Victor, > > There are some pages on the internet that suggest that this problem > my be > cause

RE: checking 'type' programmatically

2009-11-20 Thread Billy Earney
Try looking at the function 'isinstance', so for example if isinstance(obj, str): print "object is a string.." elif isinstance(obj, int): print "object is an integer.." -Original Message- From: python-list-bounces+billy.earney=gmail@python.org [mailto:python-list-boun

Re: Python Will Not Send Email!!

2009-11-20 Thread Kev Dwyer
On Fri, 20 Nov 2009 07:58:55 -0500, Victor Subervi wrote: > On Thu, Nov 19, 2009 at 5:01 PM, Kev Dwyer > wrote: > >> On Thu, 19 Nov 2009 11:28:37 -0400, Victor Subervi wrote: >> >> Hello Victor, >> >> There are some pages on the internet that suggest that this problem my >> be caused by a module

Re: checking 'type' programmatically

2009-11-20 Thread exarkun
On 10:10 am, mrk...@gmail.com wrote: Disclaimer: this is for exploring and debugging only. Really. I can check type or __class__ in the interactive interpreter: Python 2.6.2 (r262:71600, Jun 16 2009, 16:49:04) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 Type "help", "copyright", "credits

Re: Writing a Carriage Return in Unicode

2009-11-20 Thread sturlamolden
On 19 Nov, 01:14, Doug wrote: > Thanks for your help!! A carriage return in unicode is u"\r" how this is written as bytes is dependent on the encoder. Don't try to outsmart the UTF-8 codec, it knows how to translate "\r" to UTF-8. Sturla Molden -- http://mail.python.org/mailman/listinfo

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Diez B. Roggisch
DreiJane schrieb: NB: I wondered about about dict(one=1, two=2) - why not d = {one:1, two:2} ? Since you do not write L=list((1, 2)) either. These composed because it's not working. >>> {one : 1} Traceback (most recent call last): File "", line 1, in NameError: name 'one' is not defined Y

Re: Python/HTML integration: phileas v0.3 released

2009-11-20 Thread papa hippo
On 20 nov, 09:02, Stefan Behnel wrote: > papa hippo, 19.11.2009 19:53: > > > The prime goal of 'phileas' is to enable html code to be seamlessly > > included in python code in a natural looking syntax, without resorting > > to templatng language. > > I assume you know XIST, ElementTree's ElementMa

Re: Python/HTML integration: phileas v0.3 released

2009-11-20 Thread papa hippo
On 19 nov, 20:18, Steve Howell wrote: > On Nov 19, 10:53 am, papa hippo wrote: > > > The prime goal of 'phileas' is to enable html code to be seamlessly > > included in python code in a natural looking syntax, without resorting > > to templatng language. > > > see: > > >http://larry.myerscough.nl

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread DreiJane
NB: I wondered about about dict(one=1, two=2) - why not d = {one:1, two:2} ? Since you do not write L=list((1, 2)) either. These composed objects as basic building blocks make Python code so dense and beautiful, thus using "{}" means embracing the language's concept. -- http://mail.python.org/mail

Announcement: depikt - the minimalistic python gate to gtk

2009-11-20 Thread DreiJane
Hi all, these days i make depikt, a python C-extension for building apps with gtk. It was a challenge for me and big fun. From its short description on sourceforge.net: "Python-3 wrappers for GTK. A minimalistic approach - just suited for GUI-building of apps, in no way for widget-building. Curre

Re: Does turtle graphics have the wrong associations?

2009-11-20 Thread Robert Maas, http://tinyurl.com/uh3t
> > My proposed no-syntax > > IDE *also* gets rid of the need to bother with any programming-language > > syntax. I've been proposing it for years, but nobody has shown any > > interest > From: Steven D'Aprano > I'm interested. No-syntax IDE? How is this even possible? I guess you missed what I p

Book: Programming Python 3 (Second Edition) now available

2009-11-20 Thread Mark Summerfield
Hi, I'm delighted to announce that a new edition of my Python 3 book is now available in the U.S. "Programming in Python 3 (Second Edition): A Complete Introduction to the Python Language" ISBN 0321680561 http://www.qtrac.eu/py3book.html The book has been fully revised and updated and now covers

Re: Is an interactive command a block?

2009-11-20 Thread Benjamin Kaplan
On Thu, Nov 19, 2009 at 4:42 PM, Alf P. Steinbach wrote: > * Steven D'Aprano: >> >> On Thu, 19 Nov 2009 21:37:17 +0100, Alf P. Steinbach wrote: >> >>> The CPython 3.1.1 language reference §4.1 says >>> >>>   "Each command typed interactively is a block." >>> >>> It also says >>> >>>   "If a name i

Re: Python Will Not Send Email!!

2009-11-20 Thread Victor Subervi
On Thu, Nov 19, 2009 at 5:01 PM, Kev Dwyer wrote: > On Thu, 19 Nov 2009 11:28:37 -0400, Victor Subervi wrote: > > Hello Victor, > > There are some pages on the internet that suggest that this problem my be > caused by a module named email.py (or email.pyc) in your pythonpath. If > you try import

Regexp and multiple groups (with repeats)

2009-11-20 Thread mk
Hello, >>> r=re.compile(r'(?:[a-zA-Z]:)([\\/]\w+)+') >>> r.search(r'c:/tmp/spam/eggs').groups() ('/eggs',) Obviously, I would like to capture all groups: ('/tmp', '/spam', '/eggs') But it seems that re captures only the last group. Is there any way to capture all groups with repeat following

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Simon Brunning
2009/11/20 Michele Simionato : > Yes, but only in Python 3: > {(i, x) for i, x in enumerate('abc')} > {(0, 'a'), (1, 'b'), (2, 'c')} In Python 2.x, you can do: >>> dict((i, x) for i, x in enumerate('abc')) {0: 'a', 1: 'b', 2: 'c'} (Works in 2.5 - I can't remember when generator expressions

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Dave Angel
Peng Yu wrote: I'm wondering if there is something similar to list comprehension for dict (please see the example code below). d = dict(one=1, two=2) print d def fun(d):#Is there a way similar to list comprehension to change the argument d so that d is changed? d=dict(three=3) fun(d) print

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Tim Golden
Michele Simionato wrote: On Nov 20, 4:18 am, Peng Yu wrote: I'm wondering if there is something similar to list comprehension for dict Yes, but only in Python 3: {(i, x) for i, x in enumerate('abc')} {(0, 'a'), (1, 'b'), (2, 'c')} Although the 2.x syntax is hardly onerous: dict ((i+5, x

Re: Python/HTML integration: phileas v0.3 released

2009-11-20 Thread Daniel Fetchinson
>> The prime goal of 'phileas' is to enable html code to be seamlessly >> included in python code in a natural looking syntax, without resorting >> to templatng language. >> >> see: >> >> http://larry.myerscough.nl/phileas_project/ >> >> I intend to submit phileas to the python.announce forum with

Re: python simply not scaleable enough for google?

2009-11-20 Thread Robin Becker
Aahz wrote: In article , Robert P. J. Day wrote: http://groups.google.com/group/unladen-swallow/browse_thread/thread/4edbc406f544643e?pli=1 thoughts? Haven't seen this elsewhere in the thread: http://dalkescientific.com/writings/diary/archive/2009/11/15/10_tasklets.html I looked at

checking 'type' programmatically

2009-11-20 Thread mk
Disclaimer: this is for exploring and debugging only. Really. I can check type or __class__ in the interactive interpreter: Python 2.6.2 (r262:71600, Jun 16 2009, 16:49:04) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Andre Engels
On Fri, Nov 20, 2009 at 4:18 AM, Peng Yu wrote: > I'm wondering if there is something similar to list comprehension for > dict (please see the example code below). > > > d = dict(one=1, two=2) > print d > > def fun(d):#Is there a way similar to list comprehension to change the > argument d so that

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Terry Reedy
Peng Yu wrote: I'm wondering if there is something similar to list comprehension for dict (please see the example code below). Python 3 has list, set, and dict comprehensions. Don't know about 2.6/7 -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Paul Rudin
Patrick Sabin writes: > Peng Yu wrote: >> I'm wondering if there is something similar to list comprehension for >> dict (please see the example code below). > > Do you mean something like this: > {i:i+1 for i in [1,2,3,4]} > {1: 2, 2: 3, 3: 4, 4: 5} > > This works in python3, but not in pyth

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Patrick Sabin
Peng Yu wrote: I'm wondering if there is something similar to list comprehension for dict (please see the example code below). Do you mean something like this: >>> {i:i+1 for i in [1,2,3,4]} {1: 2, 2: 3, 3: 4, 4: 5} This works in python3, but not in python2 - Patrick -- http://mail.python.or

Re: non-copy slices

2009-11-20 Thread Ajit Kumar
On Thu, Nov 19, 2009 at 8:14 PM, Ethan Furman wrote: >> No I'm well aware that there is no deep copy of the objects and the lists >> only keep references to the objects and in essence they have the same >> objects in there. But this doesn't mean they are the same list. >> Modifications to slices a

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Stefan Behnel
Stefan Behnel, 20.11.2009 09:24: > You can use d.update(...) > > It accepts both another dict as well as a generator expression that > produces item tuples, e.g. > > d.update( (i, i**2) for i in range(10) ) This also works, BTW: >>> d = {} >>> d.update(value=5) >>> d {'valu

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Stefan Behnel
Peng Yu, 20.11.2009 04:18: > I'm wondering if there is something similar to list comprehension for > dict (please see the example code below). A list comprehension is an expression that produces a list, e.g. [ i**2 for i in range(10) ] Your example below uses a slice assignment. > def fun(

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Michele Simionato
On Nov 20, 4:18 am, Peng Yu wrote: > I'm wondering if there is something similar to list comprehension for > dict Yes, but only in Python 3: >>> {(i, x) for i, x in enumerate('abc')} {(0, 'a'), (1, 'b'), (2, 'c')} -- http://mail.python.org/mailman/listinfo/python-list

Re: Python/HTML integration: phileas v0.3 released

2009-11-20 Thread Stefan Behnel
papa hippo, 19.11.2009 19:53: > The prime goal of 'phileas' is to enable html code to be seamlessly > included in python code in a natural looking syntax, without resorting > to templatng language. I assume you know XIST, ElementTree's ElementMaker, and all those other ways of generating XML/HTML

Re: DOM related question and problem

2009-11-20 Thread Stefan Behnel
elca, 18.11.2009 19:04: > 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 can extract such like following info quickly? This should help: http://blog.ianbicking.org/2008/12/10/lxml-an

Re: ANN: Urwid 0.9.9 - Console UI Library

2009-11-20 Thread Tim Roberts
"Michel Claveau - MVP" wrote: > >Hi! > >You forget to write "urwid" do not run under Windows. He also forgot to write "urwid" do not run under CP/M or OS/360. Why did you feel compelled to post this three times? If it supported Windows, it would say so. The fact that it doesn't say so means it

Re: Writing a Carriage Return in Unicode

2009-11-20 Thread Scott David Daniels
MRAB wrote: u'\u240D' isn't a carriage return (that's u'\r') but a symbol (a visible "CR" graphic) for carriage return. Windows programs normally expect lines to end with '\r\n'; just use u'\n' in programs and open the text files in text mode ('r' or 'w'). This is the one thing from standards

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

2009-11-20 Thread John Nagle
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 Unicode is very si

Re: FYI: ConfigParser, ordered options, PEP 372 and OrderedDict + big thank you

2009-11-20 Thread Scott David Daniels
Jonathan Fine wrote:... A big thanks to Armin Ronacher and Raymond Hettinger for PEP 372: Adding an ordered dictionary to collections ... I prototyped (in about an hour). I then thought - maybe someone has been down this path before So all that I want has been done already, and will be

Re: python bijection

2009-11-20 Thread Joshua Bronson
On Nov 19, 9:17 pm, Carl Banks wrote: > Apart from the GPL what Ben said :) > it seems perfectly fine to release, and looks like > an interesting strategy. I've wanted one of those once in a while, > never enough to bother looking for one or writing one myself. glad to hear it! i'll release it

Re: python bijection

2009-11-20 Thread Ben Finney
Carl Banks writes: > On Nov 19, 3:24 pm, Joshua Bronson wrote: > > I couldn't find a library providing a bijective map data structure > > (allowing for constant-time lookups by value) in the few minutes I > > looked, so I took a few more minutes to code one > > up:http://bitbucket.org/jab/toys/s

Re: python bijection

2009-11-20 Thread Carl Banks
On Nov 19, 3:24 pm, Joshua Bronson wrote: > I couldn't find a library providing a bijective map data structure > (allowing for constant-time lookups by value) in the few minutes I > looked, so I took a few more minutes to code one > up:http://bitbucket.org/jab/toys/src/tip/bijection.py > > Is thi

Re: Whom Must We Worship

2009-11-20 Thread furlan
On Sun, 15 Nov 2009 00:17:43 -0800, Mary wrote: > Whom Must We Worship > The Decision is yours! Thank you, I got that. I choose Python. Thanks for sharing. ciao, f -- aa #2301 "...The word that separates that which is dead from that which is livingIn the beginning was the word and tha

Re: python bijection

2009-11-20 Thread Joshua Bronson
On Nov 19, 7:05 pm, Steven D'Aprano wrote: > If I want a mapping a <-> b, I generally just create a dict {a:b, b:a}. > What is the advantages or disadvantages of your code over the simplicity > of the dict approach? Well for one, you don't have to manually update the mapping from b -> a if ever t

  1   2   >