Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto
Leo Kislov wrote: > Confirmed on windows with 2.4 and 2.5: > > C:\p>\Python24\python.exe bzp.py > line number: 588317 > '\x1e' > '' > > C:\p>\Python25\python.exe bzp.py > line number: 588317 > '\x1e' > '' > > Looks like one byte of garbage is appended at the end of file. Please > file a bug report.

Re: Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto
Fredrik Lundh wrote: > Clodoaldo Pinto Neto wrote: > > > The offending file is 5.5 MB. Sorry, i could not reproduce this problem > > with a smaller file. > > but surely you can post the repr() of the last two lines? This is the output: $ python bzp.py line number: 588

Problem reading with bz2.BZ2File(). Bug?

2006-11-15 Thread Clodoaldo Pinto Neto
lines += 1 if line1 != line2: print 'line number:', lines print repr(line1) print repr(line2) f1.close() f2.close() ## The offending file is 5.5 MB. Sorry, i could not reproduce this problem with a smaller file. http://fahstats.c

Re: Output from subprocess.Popen()

2006-10-17 Thread Clodoaldo Pinto Neto
Fredrik Lundh wrote: > Clodoaldo Pinto Neto wrote: > > > But I still don't understand what is happening. The manual says that > > when shell=True the executable argument specifies which shell to use: > > no, it says that when shell=True, it runs the command "thro

Re: Output from subprocess.Popen()

2006-10-16 Thread Clodoaldo Pinto Neto
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I can't see any obvious way to ask subprocess to use a shell other than > > the default. > > -c ? > > >>> f = Popen(["/bin/bash", "-c", "set|grep IFS"], stdout=PIPE) > >>> f.stdout.read() > "IFS=$' \\t\\n'\n" > >>> f = Popen(["/bin/sh", "-c",

Re: Output from subprocess.Popen()

2006-10-16 Thread Clodoaldo Pinto Neto
Now we have 3 different outputs from 3 people to the command: >>> f = subprocess.Popen("set | grep IFS", shell=True, stdout=subprocess.PIPE) >>> f.stdout.readlines() >From me on FC5: ["BASH_EXECUTION_STRING='set | grep IFS'\n", "IFS=' \t\n"] >From Fredrik Lundh on unknown

Re: Output from subprocess.Popen()

2006-10-15 Thread Clodoaldo Pinto Neto
Fredrik Lundh wrote: > this works for me: > > >>> f = subprocess.Popen("set | grep IFS", shell=True, > stdout=subprocess.PIPE) > >>> f.stdout.readlines() > ["IFS=$' \\t\\n'\n"] > > what does the above return on your machine? >>> f = subprocess.Popen("set | grep IFS", shell=True, stdout=subproce

Output from subprocess.Popen()

2006-10-15 Thread Clodoaldo Pinto Neto
27; \t\n" Both outputs for comparison: IFS=$' \t\n' "IFS=' \t\n" The subprocess.Popen() output is missing the $ and the last ' How to get the raw shell output from subprocess.Popen()? Regards, Clodoaldo Pinto Neto -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI Tutorial

2006-10-06 Thread Clodoaldo Pinto Neto
[EMAIL PROTECTED] wrote: > Clodoaldo Pinto Neto wrote: > > > print 'The submited name was "' + name + '"' > > Bzzt! Script injection security hole. See cgi.escape and use it (or a > similar function) for *all* text -> HTML output. >

Re: CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
le-structure, etc), > and thus should only be used while debugging, and turned off in > any sort of production code. Yes, another warning was issued. Thanks for your help. Clodoaldo Pinto Neto -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
Clodoaldo Pinto Neto wrote: > I'm just building a Python CGI Tutorial and would appreciate any > feedback from the many experts in this list. http://webpython.codepoint.net -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
Clodoaldo Pinto Neto wrote: > I'm just building a Python CGI Tutorial and would appreciate any > feedback from the many experts in this list. http://webpython.codepoint.net -- http://mail.python.org/mailman/listinfo/python-list

CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
I'm just building a Python CGI Tutorial and would appreciate any feedback from the many experts in this list. Regards, Clodoaldo Pinto Neto -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting using dictionaries

2006-04-22 Thread Clodoaldo Pinto
Thank you guys, you are great! -- http://mail.python.org/mailman/listinfo/python-list

String formatting using dictionaries

2006-04-22 Thread Clodoaldo Pinto
I know how to format strings using a dictionary: >>> d = {'list':[0, 1]} >>> '%(list)s' % d '[0, 1]' Is it possible to reference an item in the list d['list']?: >>> '%(list[0])s' % d Traceback (most recent call

Re: String To Dict Problem

2006-04-22 Thread Clodoaldo Pinto
Michael Spencer wrote: > Alternatively, you could edit visitName to allow 'True' and any other > identifiers you specify e.g. (untested): > > allowed = {"True": True, "False": False} > def visitName(self,node, **kw): > try: > return self.allowed[node.name] > e

Re: String To Dict Problem

2006-04-21 Thread Clodoaldo Pinto
) File "safe_eval.py", line 19, in visit return meth(node, **kw) File "safe_eval.py", line 47, in visitName node.name, node) __main__.Unsafe_Source_Error: Line 1. Strings must be quoted: True This is just to let you know. I can live with that. I just replace True for 1. Regards, Clodoaldo Pinto -- http://mail.python.org/mailman/listinfo/python-list

How to create a dictionary from a string?

2006-04-21 Thread Clodoaldo Pinto
Is there a simple way to build a dictionary from a string without using eval()? >>> s = '{"a":1}' >>> d = eval(s) >>> d {'a': 1} Regards, Clodoaldo Pinto -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming Tutorial for absolute beginners

2006-04-11 Thread Clodoaldo Pinto
Frank Millman wrote: > Marc 'BlackJack' Rintsch wrote: > > In <[EMAIL PROTECTED]>, Frank Millman > > wrote: > > > > > Then you can mention that, if they just want the integer portion, they > > > can use int(3/2). I think that most people with the slightest > > > understanding of basic arithmetic wi

Re: Programming Tutorial for absolute beginners

2006-04-09 Thread Clodoaldo Pinto
Frank Millman wrote: > > We know that Python is in the process of changing the division > operator. The main reason for the change is that the current approach > is not intuitive to a newcomer (whether experienced or not). > > Why not think to the future, and do it like this. Instruct the reader >

Re: Programming Tutorial for absolute beginners

2006-04-09 Thread Clodoaldo Pinto
Duncan Smith wrote: > > But as you use conversions to float in order to avoid integer division > in your code examples, it might be best to explain what's going on, even > if you do have to explain the relevant types. > I changed the comments in the first program that uses float() to: # The raw_i

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Clodoaldo Pinto
Duncan Smith wrote: > James wrote: > > Perhaps use the phrase "whole number" there and mention that in > > programming they're called integers. Having a glossary with > > definitions for things like integer, float etc etc. would be good if > > when you talked about integers it linked to the glossar

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Clodoaldo Pinto
John Salerno wrote: > Clodoaldo Pinto wrote: > > > "Python is a remarkably powerful dynamic programming language that is > > used in a wide variety of application domains. Python is often compared > > to Tcl, Perl, Ruby, Scheme or Java. Some of its key distin

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Clodoaldo Pinto
James wrote: > On the calculator page you describe the difference between 3.0 / 2 and > 3 / 2, but an absolute beginner probably wouldn't know about the > difference between integers and floats, or even what the two terms > meant. If you don't know much about computers then the fact that they > are

Re: Programming Tutorial for absolute beginners

2006-04-08 Thread Clodoaldo Pinto
Bruno Desthuilliers wrote: > Clodoaldo Pinto a écrit : > > bill pursell wrote: > > > (snip) > >>2) In the section on installing, you begin with: > >>"Python is an interpreted, interactive, object-oriented programming > >>language.". The comp

Re: Programming Tutorial for absolute beginners

2006-04-07 Thread Clodoaldo Pinto
John Salerno wrote: > > Also, is the section called "pretty printing" mistitled? Doesn't that > name refer to the pprint module? > I didn't think about pprint. I used pretty in the sense of "Pleasing or attractive in a graceful or delicate way." (dictionary) If you have any suggestions for that pa

Re: Programming Tutorial for absolute beginners

2006-04-07 Thread Clodoaldo Pinto
bill pursell wrote: > 1) in the section on the interactive interpreter you have the sentence: > "In Linux open a shell and type python (must be lower case)". It > would be nice if the word 'python' were in a different font, or perhaps > in quotes, or something. You're targetting the "absolute beg

Programming Tutorial for absolute beginners

2006-04-07 Thread Clodoaldo Pinto
I'm starting a programming tutorial for absolute beginners using Python and I would like your opinions. http://programming-crash-course.com Regards, Clodoaldo Pinto -- http://mail.python.org/mailman/listinfo/python-list