Re: More stuff added to ch 2 of my programming intro

2009-12-13 Thread Alf P. Steinbach
* Alf P. Steinbach: Format: PDF http://preview.tinyurl.com/ProgrammingBookP3> The new stuff, section 2.7, is about programs as simulations and handling data, focusing on modeling things. It includes some Python GUI programming. The plan is to discuss containers like lists and dictionaries

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Terry Reedy
On 12/13/2009 11:33 PM, exar...@twistedmatrix.com wrote: But if you mistakenly don't catch it, and you're trying to debug your code to find this mistake, you probably won't be aided in this pursuit by the exception-swallowing behavior of generator expressions. As I remember, it was the call to

Re: read text file byte by byte

2009-12-13 Thread sjdevn...@yahoo.com
On Dec 13, 5:56 pm, "Rhodri James" wrote: > On Sun, 13 Dec 2009 06:44:54 -, Steven D'Aprano   > > wrote: > > On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: > > >> Thank you all. > >> Dennis I really liked you solution for the issue but I have two question > >> about it: > >> 1) My origin

Re: Parsing html with Beautifulsoup

2009-12-13 Thread Johann Spies
On Sun, Dec 13, 2009 at 07:58:55AM -0300, Gabriel Genellina wrote: > this code should serve as a starting point: Thank you very much! > cell.findAll(text=True) returns a list of all text nodes inside a > cell; I preprocess all \n and   in each text node, and > join them all. lines is a list of

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Terry Reedy
On 12/13/2009 10:29 PM, exar...@twistedmatrix.com wrote: Doesn't matter. Sometimes it makes sense to call it directly. It only makes sense to call next (or .__next__) when you are prepared to explicitly catch StopIteration within a try..except construct. You did not catch it, so it stopped e

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오후12시42분, Steven D'Aprano wrote: > On Sun, 13 Dec 2009 17:19:17 -0800, knifenomad wrote: > > this makes the set type hashable. > > > class Set(set): > >     __hash__ = lambda self: id(self) > > That's a *seriously* broken hash function. > > >>> key = "voila" > >>> d = { Set(key): 1 } >

Re: Dangerous behavior of list(generator)

2009-12-13 Thread exarkun
On 04:11 am, ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Dec 2009 22:45:58 +, exarkun wrote: On 08:18 pm, st...@remove-this-cybersource.com.au wrote: On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: StopIteration is intended to be used only within the .__next__ method of ite

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Steven D'Aprano
On Sun, 13 Dec 2009 22:45:58 +, exarkun wrote: > On 08:18 pm, st...@remove-this-cybersource.com.au wrote: >>On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: StopIteration is intended to be used only within the .__next__ method of iterators. The devs know that other 'off-label' us

Re: insert unique data in a list

2009-12-13 Thread Steven D'Aprano
On Sun, 13 Dec 2009 17:19:17 -0800, knifenomad wrote: > this makes the set type hashable. > > class Set(set): > __hash__ = lambda self: id(self) That's a *seriously* broken hash function. >>> key = "voila" >>> d = { Set(key): 1 } >>> d {Set(['i', 'a', 'l', 'o', 'v']): 1} >>> d[ Set(key) ]

Re: power of explicit self?

2009-12-13 Thread Tim Roberts
Fire Crow wrote: >> It's not implemented in the compiler. There's a place in the runtime >> for invoking a method where the object is inserted at the beginning >> of the parameter list. IIRC, that's done by wrapping the function >> object. > >This is the source of Objects/methodobject.c it look l

Re: Dangerous behavior of list(generator)

2009-12-13 Thread exarkun
On 02:50 am, lie.1...@gmail.com wrote: On 12/14/2009 9:45 AM, exar...@twistedmatrix.com wrote: On 08:18 pm, st...@remove-this-cybersource.com.au wrote: On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: StopIteration is intended to be used only within the .__next__ method of iterators. The dev

Re: read text file byte by byte

2009-12-13 Thread MRAB
Nobody wrote: On Sun, 13 Dec 2009 12:39:26 -0800, Dennis Lee Bieber wrote: You originally stated that you want to "scramble" the bytes -- if you mean to implement some sort of encryption algorithm you should know that most of them work in blocks as the "key" is longer than one byte. B

Re: read text file byte by byte

2009-12-13 Thread Nobody
On Sun, 13 Dec 2009 12:39:26 -0800, Dennis Lee Bieber wrote: > You originally stated that you want to "scramble" the bytes -- if > you mean to implement some sort of encryption algorithm you should know > that most of them work in blocks as the "key" is longer than one byte. Block ciphers w

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Lie Ryan
On 12/14/2009 9:45 AM, exar...@twistedmatrix.com wrote: On 08:18 pm, st...@remove-this-cybersource.com.au wrote: On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: StopIteration is intended to be used only within the .__next__ method of iterators. The devs know that other 'off-label' use result

Re: Moving from PHP to Python. Is it Possible

2009-12-13 Thread Lie Ryan
On 12/14/2009 12:04 PM, Sancar Saran wrote: On Monday 14 December 2009 02:10:16 am Diez B. Roggisch wrote: In my usage GLOBALS are too much useful to discard it. The problem with global variables is their scope. If you have a piece of code, the important thing to know is what influences it's b

Introduction to Python: Change of Dates

2009-12-13 Thread Steve Holden
Please note that the dates of our upcoming "Introduction to Python" three-day class have been changed to avoid the federal holiday on Martin Luther King Day. The class will now run from January 19-21. Details at http://hwebpyintnyc01.eventbrite.com/ regards Steve -- Steve Holden +1

Re: insert unique data in a list

2009-12-13 Thread Lie Ryan
On 12/14/2009 11:49 AM, Fire Crow wrote: I also think that if every api has to conform to every other api nothing will ever get done. but if every object has its own distinct API, we will never finish reading the docs (assuming they do exist for each object). -- http://mail.python.org/mailman

Re: Moving from PHP to Python. Is it Possible

2009-12-13 Thread Nobody
On Fri, 11 Dec 2009 12:26:30 +0200, Sancar Saran wrote: > 1-) Can I create Global (read/write access anywhere from my code) Multi > dimensional, associative array (or hash) and store any kind of variable type. Global, no; at least not in the sense of e.g. C. Python doesn't have a global namespa

Re: insert unique data in a list

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 5:19 PM, knifenomad wrote: > On 12월14일, 오전2시57분, mattia wrote: >> Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: >> > How can I insert non-duplicate data in a list? I mean, is there a >> > particular option in the creation of a list that permit me not to use >> > s

Re: Nanoengineer-1 Simulator

2009-12-13 Thread technologiclee
On Dec 13, 12:34 am, technologiclee wrote: > This is from a thread started at the Open Manufacturing Group. > > It is about the Nanoengineer-1 molecular modeling program. > It is released under GPL license. I would like to know if this project > can be forked and continued - as development seems t

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오전10시19분, knifenomad wrote: > On 12월14일, 오전2시57분, mattia wrote: > > > > > > > Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: > > > > How can I insert non-duplicate data in a list? I mean, is there a > > > particular option in the creation of a list that permit me not to use > >

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오전2시57분, mattia wrote: > Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: > > > How can I insert non-duplicate data in a list? I mean, is there a > > particular option in the creation of a list that permit me not to use > > something like: > > def append_unique(l, val): > >     if

Re: Moving from PHP to Python. Is it Possible

2009-12-13 Thread Sancar Saran
On Monday 14 December 2009 02:10:16 am Diez B. Roggisch wrote: > >> 1) PHP does some really nasty things in how it treats globals, and you > >> will have to break yourself of those sorts of habits -- Python offers > >> much cleaner alternatives, like grouping similar functionality into > >> modules

Re: insert unique data in a list

2009-12-13 Thread Fire Crow
> Also, I'm not sure I like your abuse of the + operator to modify the > object in place and return a flag. It is an API not shared by (as far as > I can see) any other data type in Python. I agree it couuld be more consisten with other object apis, I also think that if every api has to conform t

Re: Moving from PHP to Python. Is it Possible

2009-12-13 Thread Diez B. Roggisch
1) PHP does some really nasty things in how it treats globals, and you will have to break yourself of those sorts of habits -- Python offers much cleaner alternatives, like grouping similar functionality into modules which can be imported; the import functionality in python is pretty flexible. Pyt

Re: insert unique data in a list

2009-12-13 Thread geremy condra
On Sun, Dec 13, 2009 at 3:09 PM, Steven D'Aprano wrote: > On Sun, 13 Dec 2009 10:48:11 -0800, Fire Crow wrote: > >> You could also define a custom object that manages a custom ordered set > [...] >> I've used this on a few projects, it makes for wonderfully clean code, >> because you can look at y

Re: read text file byte by byte

2009-12-13 Thread Rhodri James
On Sun, 13 Dec 2009 06:44:54 -, Steven D'Aprano wrote: On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote: Thank you all. Dennis I really liked you solution for the issue but I have two question about it: 1) My origin file is Text file and not binary That's a statement, not a question

Re: Dangerous behavior of list(generator)

2009-12-13 Thread exarkun
On 08:18 pm, st...@remove-this-cybersource.com.au wrote: On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: StopIteration is intended to be used only within the .__next__ method of iterators. The devs know that other 'off-label' use results in the inconsistency you noted, but their and my view

Re: Perl to Python conversion

2009-12-13 Thread Martin Schöön
r0g writes: > > I'd recommend you start from scratch and refer to the perl version if > and when you need to. That is my plan. > You'll probably find the majority of code in a GUI > app is boring window handling stuff rather, often this is machine > generated (by progs like glade) rather than ha

Re: pyZui - anyone know about this?

2009-12-13 Thread David Boddie
On Friday 11 December 2009 05:41, Donn wrote: > I happened upon this youtube link: > http://www.youtube.com/watch?v=57nWm984wdY > It fairly blew my socks off. In it a fellow by the name of David Roberts > demos a zui written in Python. Aside from the zooming (which is impressive > enough) it show

Re: Another MySQL Problem

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 1:37 PM, MRAB wrote: > 2. Did you commit the changes? > Ah, yes, caught me napping! db.commit() has bit me in the a$$ again. Thanks, V -- http://mail.python.org/mailman/listinfo/python-list

Re: Manipulating MySQL Sets

2009-12-13 Thread Dave Angel
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese wrote: Victor Subervi wrote: I need to get at the individual elements of the set (that which is between the single quotes). It's not quite clear what you mean by "get at the individual elements", so I'll just

Re: Perl to Python conversion

2009-12-13 Thread r0g
Martin Schöön wrote: > Thanks all, great response! > > A little more background: > > I am not a programmer but I have done some programming in the past. > This was all humble number crunching as part of my PhD project using > FORTRAN. I also did some Rocky Mountain Basic coding for programs > man

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Steven D'Aprano
On Sun, 13 Dec 2009 14:35:21 +, exarkun wrote: >>StopIteration is intended to be used only within the .__next__ method of >>iterators. The devs know that other 'off-label' use results in the >>inconsistency you noted, but their and my view is 'don't do that'. > > Which is unfortunate, because

Re: insert unique data in a list

2009-12-13 Thread Steven D'Aprano
On Sun, 13 Dec 2009 10:48:11 -0800, Fire Crow wrote: > You could also define a custom object that manages a custom ordered set [...] > I've used this on a few projects, it makes for wonderfully clean code, > because you can look at your program as an overview without all the > arithmetic behind it

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: PS: I have another field that's a datetime with the same problem. How do I par

Re: insert unique data in a list

2009-12-13 Thread Fire Crow
On Dec 13, 11:37 am, mattia wrote: > How can I insert non-duplicate data in a list? I mean, is there a > particular option in the creation of a list that permit me not to use > something like: > def append_unique(l, val): >     if val not in l: >         l.append(val) > > Thanks, > Mattia You cou

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: PS: I have another field that's a datetime with the same problem. How do I parse and otherwise work with that? Look at the documentation for the datetime class. -- http://mail.pyth

Re: Another MySQL Problem

2009-12-13 Thread MRAB
Victor Subervi wrote: Hi; mysql> truncate tem126072414516; Query OK, 0 rows affected (0.00 sec) Then I run a script: if whatDo == 'insert': try: sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' % (tmpTable, prodid, quantity) print sql cursor.execute(sql)

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:40 PM, Victor Subervi wrote: > On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi > wrote: > > PS: I have another field that's a datetime with the same problem. How do I > parse and otherwise work with that? > I have yet another problem with this. Once I've determined it

Re: Manipulating MySQL Sets

2009-12-13 Thread MRAB
Victor Subervi wrote: On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi mailto:sba...@clubdelarazon.org>> wrote: On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: > Who said I was expecting a string? I don't know what I'm expecting! I need

Re: unable to read the __main__ namespace

2009-12-13 Thread vsoler
On Dec 13, 12:34 pm, Chris Rebert wrote: > On Sun, Dec 13, 2009 at 3:20 AM, vsoler wrote: > > I'm learning Python, and I am very fond of it. > > > Using Python 2.6 > > > I am able to list all the names in a class namespace: > > > class abc: pass > > abc.a1=7 > > abc.a2='Text' > > > print abc.__di

Re: insert unique data in a list

2009-12-13 Thread Andreas Waldenburger
On 13 Dec 2009 17:57:47 GMT mattia wrote: > Using set does'n work (i.e. the python interpreter tells me: > TypeError: unhashable type: 'list')... Convert the lists to tuples before adding them. Tuples are hashable. /W -- INVALID? DE! -- http://mail.python.org/mailman/listinfo/python-list

Another MySQL Problem

2009-12-13 Thread Victor Subervi
Hi; mysql> truncate tem126072414516; Query OK, 0 rows affected (0.00 sec) Then I run a script: if whatDo == 'insert': try: sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' % (tmpTable, prodid, quantity) print sql cursor.execute(sql) that runs this (printed

Re: insert unique data in a list

2009-12-13 Thread Gary Herron
mattia wrote: Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val)

Re: insert unique data in a list

2009-12-13 Thread mattia
Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: > How can I insert non-duplicate data in a list? I mean, is there a > particular option in the creation of a list that permit me not to use > something like: > def append_unique(l, val): > if val not in l: > l.append(val) > > Than

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:39 PM, Victor Subervi wrote: PS: I have another field that's a datetime with the same problem. How do I parse and otherwise work with that? TIA, V -- http://mail.python.org/mailman/listinfo/python-list

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese wrote: > Victor Subervi wrote: > > I need to get at the individual elements of the set (that which is > > between the single quotes). > > It's not quite clear what you mean by "get at the individual elements", > so I'll just show you a couple of thin

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 2:10 PM, Carsten Haese wrote: from sets import Set aSet = Set(['Small', 'Extra-small', 'Medium']) You don't need to import "Set" since it is built in now: >>> a=set([1,2,2,3,4,5]) >>> a set([1, 2, 3, 4, 5]) (I have Python 2.6.2 but I think that this is availabl

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:26 AM, Sebastian Bassi wrote: > On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi > wrote: > > Who said I was expecting a string? I don't know what I'm expecting! I > need > > to be able to parse this thing, whatever it is. You say it's a Python Set > > object. How do I

Re: insert unique data in a list

2009-12-13 Thread Alf P. Steinbach
* mattia: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val) How about using a set instead? >>> a = {1, 2, 3} >>> a

Re: Manipulating MySQL Sets

2009-12-13 Thread Carsten Haese
Victor Subervi wrote: > I need to get at the individual elements of the set (that which is > between the single quotes). It's not quite clear what you mean by "get at the individual elements", so I'll just show you a couple of things you can do to a set, and maybe one of them comes close to what y

Re: Manipulating MySQL Sets

2009-12-13 Thread Robert P. J. Day
On Sun, 13 Dec 2009, Victor Subervi wrote: > On Sun, Dec 13, 2009 at 11:56 AM, Robert P. J. Day > wrote: > On Sun, 13 Dec 2009, Victor Subervi wrote: > > > On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese > > > wrote: > >       > I don't know what I'm expecting! >

Re: insert unique data in a list

2009-12-13 Thread Sean DiZazzo
On Dec 13, 8:37 am, mattia wrote: > How can I insert non-duplicate data in a list? I mean, is there a > particular option in the creation of a list that permit me not to use > something like: > def append_unique(l, val): >     if val not in l: >         l.append(val) > > Thanks, > Mattia Check ou

Re: insert unique data in a list

2009-12-13 Thread Gary Herron
mattia wrote: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val) Thanks, Mattia Unless the insertion order is importa

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:56 AM, Robert P. J. Day wrote: > On Sun, 13 Dec 2009, Victor Subervi wrote: > > > On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese > > > wrote: > > > I don't know what I'm expecting! > > > > That statement is the most succinct summary of the root cause of all > > y

Re: Manipulating MySQL Sets

2009-12-13 Thread Robert P. J. Day
On Sun, 13 Dec 2009, Victor Subervi wrote: > On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese > wrote: > > I don't know what I'm expecting! > > That statement is the most succinct summary of the root cause of all > your problems. If you don't know what to expect, how could you > possibly wri

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 11:36 AM, Carsten Haese wrote: > > I don't know what I'm expecting! > > That statement is the most succinct summary of the root cause of all > your problems. If you don't know what to expect, how could you possibly > write code that produces what you expect? (Don't answer t

insert unique data in a list

2009-12-13 Thread mattia
How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val): if val not in l: l.append(val) Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: Manipulating MySQL Sets

2009-12-13 Thread Carsten Haese
Victor Subervi wrote: > On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese > wrote: > > The traceback helpfully shows us that colValue is a 1-tuple whose zeroth > entry, colValue[0], is an actual bona-fide Python Set object. Such > objects aren't indexable,

Re: Manipulating MySQL Sets

2009-12-13 Thread Sebastian Bassi
On Sun, Dec 13, 2009 at 12:48 PM, Victor Subervi wrote: > Who said I was expecting a string? I don't know what I'm expecting! I need > to be able to parse this thing, whatever it is. You say it's a Python Set > object. How do I parse it? Googling has been disappointing. You can walk thought a set

Re: Manipulating MySQL Sets

2009-12-13 Thread Victor Subervi
On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese wrote: > The traceback helpfully shows us that colValue is a 1-tuple whose zeroth > entry, colValue[0], is an actual bona-fide Python Set object. Such > objects aren't indexable, because sets are unordered. That still doesn't > tell us where colValue

Re: parse a string of parameters and values

2009-12-13 Thread bsneddon
On Dec 13, 5:28 am, Peter Otten <__pete...@web.de> wrote: > bsneddon wrote: > > I have a problem that I can come up with a brute force solution to > > solve but it occurred to me that there may be an > >  "one-- and preferably only one --obvious way to do it". > > > I am going to read a text file t

Re: read text file byte by byte

2009-12-13 Thread Tim Chase
Grant Edwards wrote: If it's a binary file... OK, but... what is a "binary" file? One containing data encoded in base-2. Or one of a system of two files that orbits around a common center of mass? So if you see two files orbiting around a cathedral, they're binary files. f.open('binaryf

Re: Dangerous behavior of list(generator)

2009-12-13 Thread exarkun
On 08:45 am, tjre...@udel.edu wrote: Tom Machinski wrote: In most cases, `list(generator)` works as expected. Thus, `list()` is generally equivalent to `[]`. Here's a minimal case where this equivalence breaks, causing a serious and hard-to-detect bug in a program: >>> def sit(): raise StopI

Re: read text file byte by byte

2009-12-13 Thread Grant Edwards
On 2009-12-13, Michel Claveau - MVP wrote: > Hi! > >> If it's a binary file... > > OK, but... what is a "binary" file? One containing data encoded in base-2. -- Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: Graph library for Python

2009-12-13 Thread Tiago de Paula Peixoto
On 12/13/2009 08:32 AM, anand jeyahar wrote: > A crucial element in this hypothetical module would be the main graph > data structure. The simplest approach would be to implement it in pure > python, with lists, dicts and such, as many libraries do. However, this > would rule out it

Re: unable to read the __main__ namespace

2009-12-13 Thread Peter Otten
vsoler wrote: > I'm learning Python, and I am very fond of it. > > Using Python 2.6 > > I am able to list all the names in a class namespace: > > class abc: pass > abc.a1=7 > abc.a2='Text' > > print abc.__dict__.keys() > > a) However, I do not know how to read the __main__ namespace > > prin

Re: unable to read the __main__ namespace

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 3:20 AM, vsoler wrote: > I'm learning Python, and I am very fond of it. > > Using Python 2.6 > > I am able to list all the names in a class namespace: > > class abc: pass > abc.a1=7 > abc.a2='Text' > > print abc.__dict__.keys() That is more simply written as: print dir(ab

unable to read the __main__ namespace

2009-12-13 Thread vsoler
I'm learning Python, and I am very fond of it. Using Python 2.6 I am able to list all the names in a class namespace: class abc: pass abc.a1=7 abc.a2='Text' print abc.__dict__.keys() a) However, I do not know how to read the __main__ namespace print __main__.__dict__.keys()# Just does not

Re: Parsing html with Beautifulsoup

2009-12-13 Thread Gabriel Genellina
En Fri, 11 Dec 2009 04:04:38 -0300, Johann Spies escribió: Gabriel Genellina het geskryf: En Thu, 10 Dec 2009 06:15:19 -0300, Johann Spies escribió: How do I get Beautifulsoup to render (taking the above line as example) sunentint for  sunetint and still provide the text-parts in the

Re: parse a string of parameters and values

2009-12-13 Thread Peter Otten
bsneddon wrote: > I have a problem that I can come up with a brute force solution to > solve but it occurred to me that there may be an > "one-- and preferably only one --obvious way to do it". > > I am going to read a text file that is an export from a control > system. > It has lines with info

Re: Graph library for Python

2009-12-13 Thread anand jeyahar
While I agree, I think it's going to be extremely difficult to get any > kind of buy in without a great deal of support from within python. > Any devs willing to throw the time required into this? > > Geremy Condra > -- > http://mail.python.org/mailman/listinfo/python-list > yep i am interested.

Re: Graph library for Python

2009-12-13 Thread geremy condra
On Sun, Dec 13, 2009 at 3:38 AM, Terry Reedy wrote: > geremy condra wrote: > >> Well, I've just concluded a short conversation with Raymond Hettinger, >> and I think its fair to characterize him as being opposed to the idea >> at present. In addition to the popularity test, he's also noted that >>

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Gabriel Genellina
En Sat, 12 Dec 2009 23:43:20 -0300, Ned Deily escribió: In article , Ned Deily wrote: In article , Benjamin Kaplan wrote: > On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski > wrote: > > >>> def sit(): raise StopIteration() > > ... > > >>> [f() for f in (lambda:1, sit, lambda:2)]

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Gabriel Genellina
En Sat, 12 Dec 2009 23:43:20 -0300, Ned Deily escribió: In article , Ned Deily wrote: In article , Benjamin Kaplan wrote: > On Sat, Dec 12, 2009 at 7:15 PM, Tom Machinski > wrote: > > >>> def sit(): raise StopIteration() > > ... > > >>> [f() for f in (lambda:1, sit, lambda:2)]

Re: Dangerous behavior of list(generator)

2009-12-13 Thread Terry Reedy
Tom Machinski wrote: In most cases, `list(generator)` works as expected. Thus, `list()` is generally equivalent to `[]`. Here's a minimal case where this equivalence breaks, causing a serious and hard-to-detect bug in a program: >>> def sit(): raise StopIteration() StopIteration is intended

Re: Graph library for Python

2009-12-13 Thread Terry Reedy
geremy condra wrote: Well, I've just concluded a short conversation with Raymond Hettinger, and I think its fair to characterize him as being opposed to the idea at present. In addition to the popularity test, he's also noted that ideally a core CPython dev should be involved in the project. Put

Re: read text file byte by byte

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 12:20 AM, Michel Claveau - MVP wrote: > Hi! > >> If it's a binary file... > > OK, but... what is a "binary" file? http://en.wikipedia.org/wiki/Binary_file Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: read text file byte by byte

2009-12-13 Thread Michel Claveau - MVP
Hi! > If it's a binary file... OK, but... what is a "binary" file? @+ -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list