Re: C++ equivalent of comp.lang.python?

2008-01-03 Thread Russ P.
On Jan 3, 9:39 am, [EMAIL PROTECTED] wrote: > Hopefully this isn't too OT. > > One thing I like about comp.lang.python is the breadth of topics > discussed here. People can ask about Python installation and > configuration issues on specific platforms, compare third party > libraries, ask for book

Re: Problem reading csv files

2008-01-03 Thread Chris
On Jan 4, 6:24 am, Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to read a csv file using csv.reader. The file is created > using Open Office and saved in Excel format. > > import csv > > reader = csv.reader(open('test.xls')) > for row in reader: > print row > > It however

Re: linecache and glob

2008-01-03 Thread Shane Geiger
import linecache import glob # reading from one file print linecache.getline('notes/python.txt',4) 'http://www.python.org/doc/current/lib/\n' # reading from many files for filename in glob.glob('/etc/*'): print linecache.getline(filename,4) jo3c wrote: > hi everyone happy new year! > im a

Re: Information on PyGMT?

2008-01-03 Thread Jeroen Ruigrok van der Werven
-On [20080104 04:11], Alaric ([EMAIL PROTECTED]) wrote: >Unfortunately, the only site (forge.nesc.ac.uk) that seems to offer the code >(written by Magnus Hagdorn) is not responding. I don't know if that's a >temporary condition or if that site is out of commission. > >Google isn't revealing much re

Re: linecache and glob

2008-01-03 Thread jo3c
i have a 2000 files with header and data i need to get the date information from the header then insert it into my database i am doing it in batch so i use glob.glob('/mydata/*/*/*.txt') to get the date on line 4 in the txt file i use linecache.getline('/mydata/myfile.txt/, 4) but if i use linecac

i want to share my secrets with u.........

2008-01-03 Thread aquorang
i want to share my secrets with u. how to create miracles in your own life? http://www.freewebs.com/aquorang/ http://indianfriendfinder.com/go/g926592-pmem http://bigchurch.com/go/g926592-pmem -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem reading csv files

2008-01-03 Thread gsal
Well, I don't know much python, yet, but I know a csv file when I see one...and an Excel files in not a csv file. As far as I know, an Excel file is stored probably in binary and in a propriatery format...I doubt very much csv.reader would read that just like that; then again, I know nothing about

Problem reading csv files

2008-01-03 Thread Ramashish Baranwal
Hi, I am trying to read a csv file using csv.reader. The file is created using Open Office and saved in Excel format. import csv reader = csv.reader(open('test.xls')) for row in reader: print row It however throws the exception _csv.Error: : line contains NULL byte Any idea whats going wro

Re: PyObject_CallObject code dump after calling 4 times

2008-01-03 Thread grbgooglefan
On Jan 3, 8:49 pm, grbgooglefan <[EMAIL PROTECTED]> wrote: > On Jan 3, 8:02 pm, Phil Thompson <[EMAIL PROTECTED]> > wrote: > > > > > > > On Thursday 03 January 2008, grbgooglefan wrote: > > > > I have a following C++ code which uses PyObject_CallObject to evaluate > > > expressions dynamically. Thi

Im back...

2008-01-03 Thread Sam Garson
Hi there same project I am afraid... I want to put the text from the selection of a listbox into a Label when the the selection is clicked. I have it so it is put in, but it is put in when I click on the *next*selection...as in it defines the variable when I click on the desired the selection, bu

Re: linecache and glob

2008-01-03 Thread Jeremy Dillworth
Hello, Welcome to Python! glob returns a list of filenames, but getline is made to work on just one filename. So you'll need to iterate over the list returned by glob. >>> import linecache, glob >>> for filename in glob.glob('/etc/*'): >>> print linecache.getline(filename, 4) Maybe you coul

Re: Cursors in a Loop

2008-01-03 Thread Carsten Haese
On Thu, 2008-01-03 at 17:25 -0800, t_rectenwald wrote: > On Jan 3, 7:47 pm, t_rectenwald <[EMAIL PROTECTED]> wrote: > > I have a python script that uses the cx_Oracle module. I have a list > > of values that I iterate through via a for loop and then insert into > > the database. This works okay,

Information on PyGMT?

2008-01-03 Thread Alaric
Hello - I'm seeking info on the PyGMT python wrapper for the Generic Mapping Tools package. Unfortunately, the only site (forge.nesc.ac.uk) that seems to offer the code (written by Magnus Hagdorn) is not responding. I don't know if that's a temporary condition or if that site is out of commission.

linecache and glob

2008-01-03 Thread jo3c
hi everyone happy new year! im a newbie to python i have a question by using linecache and glob how do i read a specific line from a file in a batch and then insert it into database? because it doesn't work! i can't use glob wildcard with linecache >>> import linecache >>> linecache.getline(glob.

Re: problem with global var

2008-01-03 Thread Steven D'Aprano
On Thu, 03 Jan 2008 11:38:48 -0300, Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of lines > from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread Steven D'Aprano
On Thu, 03 Jan 2008 16:56:00 -0600, Reedick, Andrew wrote: > The problem occurred because a method used to generate keys was > returning a string instead of a number without an explicit conversion > taking place. And since I was using hash.get(i, default_value) to avoid > having to pair every key

lucas ares

2008-01-03 Thread lucas
visitame www.lucasares.com.ar -- http://mail.python.org/mailman/listinfo/python-list

calling system command in window is very slow in python 2.5.1

2008-01-03 Thread wang frank
Hi, I am running a python script that will change the attribute of a directory and its subdiretory by command: os.system("chmod -R .") or os.system("attrib -R * /S") Both commands chmod and attrib run quite fast in dos command shell. However, inside python, they are very slow and

Re: Cursors in a Loop

2008-01-03 Thread t_rectenwald
On Jan 3, 7:47 pm, t_rectenwald <[EMAIL PROTECTED]> wrote: > I have a python script that uses the cx_Oracle module.  I have a list > of values that I iterate through via a for loop and then insert into > the database.  This works okay, but I'm not sure whether I can use one > cursor for all inserts

Re: ctypes - pointer to array of structs?

2008-01-03 Thread Skip Montanaro
> > (Is this the right place to ask ctypes questions? There's a mailing list > > but the last post to it seems to have been in November 2006.) > > No, it's active. Thanks. I guess the official ASPN-based archive must be dead. I managed to sort of get access to the array just using indexing as

Cursors in a Loop

2008-01-03 Thread t_rectenwald
I have a python script that uses the cx_Oracle module. I have a list of values that I iterate through via a for loop and then insert into the database. This works okay, but I'm not sure whether I can use one cursor for all inserts, and define it outside of the loop, or instantiate and close the c

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread Stephen Hansen
> As a Perl monkey in the process of learning Python, I just stepped on > the "'1' (string) is not the same as 1 (integer) in regards to keys for > dictionaries/hashes" landmine. Is there a good way to ensure that > numbers represented as strings or ints do not get mixed up as keys? > Well one im

Re: py2exe command prompt whenr run

2008-01-03 Thread Fredrik Lundh
SMALLp wrote: > I'm using py2exe to port my applications on windows so user won't have > to install python and other dependencies. Everything works file except > when i run any of programs it star's command prompt before program starts. > > How can i avoid this to happen use windows= instead of

py2exe command prompt whenr run

2008-01-03 Thread SMALLp
HY! I'm using py2exe to port my applications on windows so user won't have to install python and other dependencies. Everything works file except when i run any of programs it star's command prompt before program starts. How can i avoid this to happen, and is there any other way of porting my

Re: ctypes - pointer to array of structs?

2008-01-03 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > (Is this the right place to ask ctypes questions? There's a mailing list > but the last post to it seems to have been in November 2006.) No, it's active. > Using ctypes I reference a structure which contains a pointer to an array of > another structure: > > clas

Re: dictionary/hash and '1' versus 1

2008-01-03 Thread John Machin
On Jan 4, 9:56 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > As a Perl monkey in the process of learning Python, I just stepped on > the "'1' (string) is not the same as 1 (integer) in regards to keys for > dictionaries/hashes" landmine. Congratulations. You have just stepped off the "'1' (st

ctypes - pointer to array of structs?

2008-01-03 Thread skip
(Is this the right place to ask ctypes questions? There's a mailing list but the last post to it seems to have been in November 2006.) Using ctypes I reference a structure which contains a pointer to an array of another structure: class SYMBOL(Structure): _fields_ = [("symbol", c_ch

Re: different encodings for unicode() and u''.encode(), bug?

2008-01-03 Thread John Machin
On Jan 4, 8:03 am, mario <[EMAIL PROTECTED]> wrote: > On Jan 2, 2:25 pm, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > > > Apparently for the empty string the encoding is irrelevant as it will not > > be used. I guess there is an early check for this special case in the code. > > In the module I an

dictionary/hash and '1' versus 1

2008-01-03 Thread Reedick, Andrew
As a Perl monkey in the process of learning Python, I just stepped on the "'1' (string) is not the same as 1 (integer) in regards to keys for dictionaries/hashes" landmine. Is there a good way to ensure that numbers represented as strings or ints do not get mixed up as keys? Example of the proble

Re: XML-XSD Processing/Creation.

2008-01-03 Thread xkenneth
On Jan 3, 1:55 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > paul wrote: > >> Can i create python classes based off the XSD files? What else can I > >> do with the XSD files? > > This might be worth looking at:http://www.rexx.com/~dkuhlman/#generateDS > > If it's really such a complex XML language

Re: choosing random dynamic port number

2008-01-03 Thread Fredrik Lundh
Emin.shopper Martinian.shopper wrote: > Is there a good way to choose/assign random dynamic port numbers in python? > > I had in mind something like the following, but if multiple programs are > generating random port numbers, is there a way to check if a given port > number is already taken? >

choosing random dynamic port number

2008-01-03 Thread Emin.shopper Martinian.shopper
Dear Experts, Is there a good way to choose/assign random dynamic port numbers in python? I had in mind something like the following, but if multiple programs are generating random port numbers, is there a way to check if a given port number is already taken? def GenerateDynamicPortNumber():

Re: New-style objects are not instances, apparently

2008-01-03 Thread Martin v. Löwis
> Further experimentation showed that derivation from object was the > culprit; new-style objects are not considered "instances" in the above > sense. I wasn't able to figure out a workaround. Is there one, or is > the distinction between traditional classes and built-in types only > going to get

Re: How is AI implemented

2008-01-03 Thread montyphyton
On Jan 3, 6:49 pm, "Martin Marcher" <[EMAIL PROTECTED]> wrote: > Hi, > > I know it's not a trivial field but I had some readings about > artificial intelligence lately and my personal conclusion is that it's > mostly just statistics. > > Naively explained: > > continiously gather and store informat

Re: How is AI implemented

2008-01-03 Thread kyosohma
On Jan 3, 11:49 am, "Martin Marcher" <[EMAIL PROTECTED]> wrote: > Hi, > > I know it's not a trivial field but I had some readings about > artificial intelligence lately and my personal conclusion is that it's > mostly just statistics. > > Naively explained: > > continiously gather and store informa

Re: New-style objects are not instances, apparently

2008-01-03 Thread Arnaud Delobelle
On Jan 3, 9:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have a class that derives from Exception.  In Python 2.4, > isinstance(MyClass(), types.InstanceType) was True.  In 2.5, it's > False. > > Further experimentation showed that derivation from object was the > culprit; new-style ob

Re: New-style objects are not instances, apparently

2008-01-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Further experimentation showed that derivation from object was the > culprit; new-style objects are not considered "instances" in the above > sense. I wasn't able to figure out a workaround. Is there one, or is > the distinction between traditional classes and built-in

New-style objects are not instances, apparently

2008-01-03 Thread [EMAIL PROTECTED]
I have a class that derives from Exception. In Python 2.4, isinstance(MyClass(), types.InstanceType) was True. In 2.5, it's False. Further experimentation showed that derivation from object was the culprit; new-style objects are not considered "instances" in the above sense. I wasn't able to fi

Re: different encodings for unicode() and u''.encode(), bug?

2008-01-03 Thread mario
On Jan 2, 2:25 pm, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > Apparently for the empty string the encoding is irrelevant as it will not > be used. I guess there is an early check for this special case in the code. In the module I an working on [*] I am remembering a failed encoding to allow me

Re: PyOpenGL, wxPython weird behaviour

2008-01-03 Thread Adeola Bannis
Thanks, will do... On Jan 3, 2:07 pm, [EMAIL PROTECTED] wrote: > On Jan 3, 11:50 am, Adeola Bannis <[EMAIL PROTECTED]> wrote: > > > > > Hi everyone, > > > I'm doing a project using wxPython and pyopengl, and I seem to have a > > problem rendering textures. This is code that worked before my hard >

Re: Who's to blame?

2008-01-03 Thread kyosohma
On Jan 3, 8:48 am, Nicola Musatti <[EMAIL PROTECTED]> wrote: > Hallo, > First of all I apologize for the longish example at the bottom, but > the biggest source file is automatically generated and I didn't want > to modify more than strictly necessary. Also, it would be shorter if > XML wasn't so v

Re: urllib2 disable proxy

2008-01-03 Thread Rob Wolfe
Dimitrios Apostolou <[EMAIL PROTECTED]> writes: > On Wed, 2 Jan 2008, Rob Wolfe wrote: > >> Dimitrios Apostolou <[EMAIL PROTECTED]> writes: >> >>> Hello list, >>> >>> I've been looking for a way to explicitly disable the use of proxies with >>> urllib2, no matter what the environment dictates. Unf

Re: PyOpenGL, wxPython weird behaviour

2008-01-03 Thread kyosohma
On Jan 3, 11:50 am, Adeola Bannis <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I'm doing a project using wxPython and pyopengl, and I seem to have a > problem rendering textures. This is code that worked before my hard > drive had a meltdown, but not since I re-installed everything. > > I've deter

Re: reassign to builtin possible !?

2008-01-03 Thread Chris Mellon
On Jan 3, 2008 8:05 AM, Tim Chase <[EMAIL PROTECTED]> wrote: > >> But you can't alter the values for True/False globally with this. > > > > Are you sure ? what about the following example ? > > Is this also shadowing ? > > > import __builtin__ > __builtin__.True = False > __builtin__

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-01-03 Thread Arnaud Delobelle
On Jan 3, 4:39 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Dec 29 2007, 11:10 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > > I'm considering deprecating these two functions and would like some > > feedback from the community or from people who have a background in > > functional

Re: reassign to builtin possible !?

2008-01-03 Thread Benjamin
On Jan 3, 7:04 am, Bernhard Merkle <[EMAIL PROTECTED]> wrote: > Hi there, > > I am reading Learning Python 3e from Mark Lutz and just found out that > reassigning to builtins is possible. > What is the reason, why Python allows this ? IMO this is very risky > and can lead to hard to find errors. I

Re: Treating a unicode string as latin-1

2008-01-03 Thread Fredrik Lundh
Diez B. Roggisch wrote: >> I would think it more likely that he wants to end up with u'Bob\u2019s >> Breakfast' rather than u'Bob\x92s Breakfast' although u'Dog\u2019s dinner' >> seems a probable consequence. > > If that's the case, he should read the file as string, de- and encode it > (proba

urllib timeout hole - long timeout if site doesn't send headers.

2008-01-03 Thread John Nagle
urllib has a "hole" in its timeout protection. Using "socket.setdefaulttimeout" will make urllib time out if a site doesn't open a TCP connection in the indicated time. But if the site opens the TCP connection and never sends HTTP headers, it takes about 20 minutes for the read in urllib's

Re: Treating a unicode string as latin-1

2008-01-03 Thread Diez B. Roggisch
Duncan Booth schrieb: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> ET has already decoded the CP1252 data for you. If you want UTF-8, all >> you need to do is to encode it: >> > u'Bob\x92s Breakfast'.encode('utf8') >> 'Bob\xc2\x92s Breakfast' >> > I think he is claiming that the encoding

PyOpenGL, wxPython weird behaviour

2008-01-03 Thread Adeola Bannis
Hi everyone, I'm doing a project using wxPython and pyopengl, and I seem to have a problem rendering textures. This is code that worked before my hard drive had a meltdown, but not since I re-installed everything. I've determined the problem is in the OpenGL part of my program. I do some calculat

Re: Pivot Table/Groupby/Sum question

2008-01-03 Thread petr . jakes . tpc
On Jan 3, 3:41 pm, [EMAIL PROTECTED] wrote: > Yes in the sense that the top part will have merged cells so that > Horror and Classics don't need to be repeated every time, but the > headers aren't the important part. At this point I'm more interested > in organizing the data itself and i can worry

[OT] How is AI implemented

2008-01-03 Thread Martin Marcher
Hi, I know it's not a trivial field but I had some readings about artificial intelligence lately and my personal conclusion is that it's mostly just statistics. Naively explained: continiously gather and store information and apply a default rating 1) answer "questions" with gathered informatio

C++ equivalent of comp.lang.python?

2008-01-03 Thread brzrkr0
Hopefully this isn't too OT. One thing I like about comp.lang.python is the breadth of topics discussed here. People can ask about Python installation and configuration issues on specific platforms, compare third party libraries, ask for book recommendations, and discuss current Python projects.

Re: how to use bool

2008-01-03 Thread Chris Mellon
On 03 Jan 2008 16:09:53 GMT, <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > hi, i have some code where i set a bool type variable and if the value > > is false i would like to return from the method with an error msg.. > > being a beginner I wd like some help here > > > > class myclas

Re: Who's to blame?

2008-01-03 Thread Rob Williscroft
Nicola Musatti wrote in news:92dfc2fc-0677-43c0-b34f-4f240fa40205 @e4g2000hsg.googlegroups.com in comp.lang.python: Note there is a wxpython mailinglist/newsgroup: news:gmane.comp.python.wxpython [snip] > problem lies in the fact that apparently ShowModal() does not return > when either

Adding a HTTP header to a SOAPpy request

2008-01-03 Thread Matias Surdi
Hi, Could anybody tell me which is the easier way to do a SOAP call to a web service wich requires an http header to be present? I can't figure it out. Thanks a lot Some code I'm using: import SOAPpy s = SOAPpy.SOAPProxy("http://10.3.5.128:10560/SERVICES",namespace="http://ws.mysite.com";)

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2008-01-03 Thread [EMAIL PROTECTED]
On Dec 29 2007, 11:10 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > I'm considering deprecating these two functions and would like some > feedback from the community or from people who have a background in > functional programming. Well I have just this minute used dropwhile in anger, to find

Re: How do you pass compiler option to setup.py install?

2008-01-03 Thread Emin.shopper Martinian.shopper
On Jan 3, 2008 11:24 AM, Emin.shopper Martinian.shopper < [EMAIL PROTECTED]> wrote: > How do you pass the -c option to setup.py install? After some fiddling, I figured out that you can put the following two lines in setup.cfg: [build] compiler=mingw32 It would be nice if you could somehow pass

Re: How do you pass compiler option to setup.py install?

2008-01-03 Thread Christian Heimes
Emin.shopper Martinian.shopper wrote: > Dear Experts, > > How do you pass the -c option to setup.py install? Specifically, when I try > to install zope.interfaces version 3.3 from source on a windows machine, I > get a message about using "-c mingw32". That works fine for setup.py build, > but it

How do you pass compiler option to setup.py install?

2008-01-03 Thread Emin.shopper Martinian.shopper
Dear Experts, How do you pass the -c option to setup.py install? Specifically, when I try to install zope.interfaces version 3.3 from source on a windows machine, I get a message about using "-c mingw32". That works fine for setup.py build, but it does not work for "setup.py install". Note: I wou

Re: how to use bool

2008-01-03 Thread tinnews
[EMAIL PROTECTED] wrote: > hi, i have some code where i set a bool type variable and if the value > is false i would like to return from the method with an error msg.. > being a beginner I wd like some help here > > class myclass: > . > def mymethod(self): > success=

Re: Treating a unicode string as latin-1

2008-01-03 Thread Duncan Booth
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > ET has already decoded the CP1252 data for you. If you want UTF-8, all > you need to do is to encode it: > > >>> u'Bob\x92s Breakfast'.encode('utf8') > 'Bob\xc2\x92s Breakfast' > I think he is claiming that the encoding information in the file is inc

Re: Insert to a clob field using cx_Oracle via a stored procedure

2008-01-03 Thread hinds . ja
On Jan 2, 2:01 pm, [EMAIL PROTECTED] wrote: > Hello, > > Does anyone have experience using cx_Oracle to call a stored procedure > that inserts to a clob field?  We have done this successfully via > straight SQL, but we are at a loss on how to do the same insert using > a stored procedure call.  Any

Re: how to use bool

2008-01-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > hi, i have some code where i set a bool type variable and if the value > is false i would like to return from the method with an error msg.. > being a beginner I wd like some help here > > class myclass: > . > def mymethod(self): > success

how to use bool

2008-01-03 Thread jimgardener
hi, i have some code where i set a bool type variable and if the value is false i would like to return from the method with an error msg.. being a beginner I wd like some help here class myclass: . def mymethod(self): success=True msg="all validation OK"

Re: urllib2 disable proxy

2008-01-03 Thread Dimitrios Apostolou
On Wed, 2 Jan 2008, Rob Wolfe wrote: > Dimitrios Apostolou <[EMAIL PROTECTED]> writes: > >> Hello list, >> >> I've been looking for a way to explicitly disable the use of proxies with >> urllib2, no matter what the environment dictates. Unfortunately I can't find >> a way in the documentation, a

Re: Treating a unicode string as latin-1

2008-01-03 Thread Fredrik Lundh
Simon Willison wrote: > But ElementTree gives me back a unicode string, so I get the following > error: > print u'Bob\x92s Breakfast'.decode('cp1252').encode('utf8') > Traceback (most recent call last): > File "", line 1, in > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/

Re: problem with global var

2008-01-03 Thread Fredrik Lundh
Bruno Ferreira wrote: > When I execute the program _without_ the lines 10 and 11: > > 10 if len(topsquid) > 50: > 11 topsquid = topsquid[0:50] > > it runs perfectly. > > But if I execute the program _with_ those lines, this exception is thrown: > > [EMAIL PROTECTED]:~$ python topsq

Re: Choosing a new language

2008-01-03 Thread Joachim Durchholz
Tim Roberts schrieb: > Joachim Durchholz <[EMAIL PROTECTED]> wrote: > >>> Xah Lee <[EMAIL PROTECTED]> wrote: [...] PHP and Perl are practically identical in their high-levelness or expressiveness or field of application (and syntax), >> That must have been a very, very distant point

Re: problem with global var

2008-01-03 Thread Diez B. Roggisch
Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0

Re: unicode(s, enc).encode(enc) == s ?

2008-01-03 Thread mario
On Jan 2, 9:34 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > In any case, it goes well beyond the situation that triggered my > > original question in the first place, that basically was to provide a > > reasonable check on whether round-tripping a string is successful -- > > this is in the

Who's to blame?

2008-01-03 Thread Nicola Musatti
Hallo, First of all I apologize for the longish example at the bottom, but the biggest source file is automatically generated and I didn't want to modify more than strictly necessary. Also, it would be shorter if XML wasn't so verbose ;-) The following is a wxPython/XRC toy program with a form wit

Re: problem with global var

2008-01-03 Thread wes
Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0"

Re: problem with global var

2008-01-03 Thread Matt Nordhoff
Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0"

Re: Pivot Table/Groupby/Sum question

2008-01-03 Thread patrick . waldo
Yes in the sense that the top part will have merged cells so that Horror and Classics don't need to be repeated every time, but the headers aren't the important part. At this point I'm more interested in organizing the data itself and i can worry about putting it into a new excel file later. -- h

problem with global var

2008-01-03 Thread Bruno Ferreira
Hi, I wrote a very simple python program to generate a sorted list of lines from a squid access log file. Here is a simplified version: ## 1 logfile = open ("squid_access.log", "r") 2 topsquid = [["0", "0", "0", "0", "0", "0", "0"]] 3 4 def add_sorted (list): 5

Re: unicode(s, enc).encode(enc) == s ?

2008-01-03 Thread mario
Thanks again. I will chunk my responses as your message has too much in it for me to process all at once... On Jan 2, 9:34 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > Thanks a lot Martin and Marc for the really great explanations! I was > > wondering if it would be reasonable to imagine a

Re: ElementTree should parse string and file in the same way

2008-01-03 Thread Fredrik Lundh
Stefan Behnel wrote: >> also, putting large documents in a *single* Python string can be quite >> inefficient. it's often more efficient to use lists of string fragments. > > That's a pretty general statement. Do you mean in terms of reading from that > string (which at least in lxml is a straig

CSV

2008-01-03 Thread Beema shafreen
Hi all, I have written a script to parse a CSV file: import csv def get_lines(fname): fhandle = csv.reader(open(fname,"rb")) for line in fhandle: while fhandle.next()[0] == "prot_hit_num": continue for row in fhandle: print row result = get

Re: reassign to builtin possible !?

2008-01-03 Thread Tim Chase
>> But you can't alter the values for True/False globally with this. > > Are you sure ? what about the following example ? > Is this also shadowing ? > import __builtin__ __builtin__.True = False __builtin__.True > False It doesn't seem to screw things up globally >>> import __b

Re: reassign to builtin possible !?

2008-01-03 Thread Jeroen Ruigrok van der Werven
-On [20080103 14:47], Bernhard Merkle ([EMAIL PROTECTED]) wrote: >Are you sure ? what about the following example ? >Is this also shadowing ? It is, as it is local to your current executing interpreter. Any other Python process that is currently running is unaffected by your shadowing. So a

Re: Treating a unicode string as latin-1

2008-01-03 Thread Jeroen Ruigrok van der Werven
-On [20080103 14:36], Simon Willison ([EMAIL PROTECTED]) wrote: >How can I tell Python "I know this says it's a unicode string, but I >need you to treat it like a bytestring"? Although it does not address the exact question it does raise the issue how you are using Elemen

Re: Treating a unicode string as latin-1

2008-01-03 Thread Diez B. Roggisch
Simon Willison wrote: > Hello, > > I'm using ElementTree to parse an XML file which includes some data > encoded as cp1252, for example: > > Bob\x92s Breakfast > > If this was a regular bytestring, I would convert it to utf8 using the > following: > print 'Bob\x92s Breakfast'.decode('cp12

Re: reassign to builtin possible !?

2008-01-03 Thread Diez B. Roggisch
Bernhard Merkle wrote: > On Jan 3, 2:07 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> This hal always been possible. But it's not reassigning, it's shadowing - >> which is a totally different beast. Shadowing builtins is bad style, but >> lokal to your context. Which can get nasty of course

Re: ElementTree should parse string and file in the same way

2008-01-03 Thread Stefan Behnel
Fredrik Lundh wrote: > Stefan Behnel wrote: > >>> My take on the API decision in question was always that a file is >>> inherently an XML *document*, while a string is inherently an XML >>> *fragment*. >> >> Not inherently, no. I know some people who do web processing with an XML >> document comin

Trying to build python2.5.msi

2008-01-03 Thread abhishek
Hello Group, I have compile the python source code using MSVC 8 (a.k.a VS .NET 2005) . Can i create an MSI ?? similar to one provided by the official python website. What can be the possible procedure to achieve this. I have looked into Tools/msi folder. But i dont know how it works. Thank you

Re: Treating a unicode string as latin-1

2008-01-03 Thread Duncan Booth
Simon Willison <[EMAIL PROTECTED]> wrote: > How can I tell Python "I know this says it's a unicode string, but I > need you to treat it like a bytestring"? Can you not just fix your xml file so that it uses the same encoding as it claims to use? If the xml says it contains utf8 encoded data then

Re: reassign to builtin possible !?

2008-01-03 Thread Bernhard Merkle
On Jan 3, 2:07 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > This hal always been possible. But it's not reassigning, it's shadowing - > which is a totally different beast. Shadowing builtins is bad style, but > lokal to your context. Which can get nasty of course, if you do the above > on e.

Re: Treating a unicode string as latin-1

2008-01-03 Thread Paul Hankin
On Jan 3, 1:31 pm, Simon Willison <[EMAIL PROTECTED]> wrote: > How can I tell Python "I know this says it's a unicode string, but I > need you to treat it like a bytestring"? u'Bob\x92s Breakfast'.encode('latin-1') -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list

Treating a unicode string as latin-1

2008-01-03 Thread Simon Willison
Hello, I'm using ElementTree to parse an XML file which includes some data encoded as cp1252, for example: Bob\x92s Breakfast If this was a regular bytestring, I would convert it to utf8 using the following: >>> print 'Bob\x92s Breakfast'.decode('cp1252').encode('utf8') Bob's Breakfast But Ele

Re: reassign to builtin possible !?

2008-01-03 Thread Diez B. Roggisch
Bernhard Merkle wrote: > Hi there, > > I am reading Learning Python 3e from Mark Lutz and just found out that > reassigning to builtins is possible. > What is the reason, why Python allows this ? IMO this is very risky > and can lead to hard to find errors. > (see also Learning Python 3e, Chapter

Re: Installing pcaplib

2008-01-03 Thread Diez B. Roggisch
ashish wrote: > Hi All, > > I am trying to install "pylibpcap-0.6.1" but i am getting these errors . > > > python ./setup.py install > > . > . > . > . > . > > constants.c:172: (near initialization for `pcapmodule_DLT[52]') > pcap.c: In function `init_pcap': > pcap.c:4246: structure has no mem

reassign to builtin possible !?

2008-01-03 Thread Bernhard Merkle
Hi there, I am reading Learning Python 3e from Mark Lutz and just found out that reassigning to builtins is possible. What is the reason, why Python allows this ? IMO this is very risky and can lead to hard to find errors. (see also Learning Python 3e, Chapter 16, Page 315) >>> True True >>> Fals

Re: Cloning Environments

2008-01-03 Thread gamename
> > You might be interested in workingenv.py/virtualenv.py > Thanks! That looks promising. -T -- http://mail.python.org/mailman/listinfo/python-list

Installing pcaplib

2008-01-03 Thread ashish
Hi All, I am trying to install "pylibpcap-0.6.1" but i am getting these errors . python ./setup.py install . . . . . constants.c:172: (near initialization for `pcapmodule_DLT[52]') pcap.c: In function `init_pcap': pcap.c:4246: structure has no member named `value' pcap.c:4260: warning: passing

Re: PyObject_CallObject code dump after calling 4 times

2008-01-03 Thread grbgooglefan
On Jan 3, 8:02 pm, Phil Thompson <[EMAIL PROTECTED]> wrote: > On Thursday 03 January 2008, grbgooglefan wrote: > > > I have a following C++ code which uses PyObject_CallObject to evaluate > > expressions dynamically. This code sets the input parameters for the > > function also dynamically. After c

Re: ElementTree should parse string and file in the same way

2008-01-03 Thread Fredrik Lundh
Stefan Behnel wrote: >> My take on the API decision in question was always that a file is >> inherently an XML *document*, while a string is inherently an XML >> *fragment*. > > Not inherently, no. I know some people who do web processing with an XML > document coming in as a string (from an HTTP

Re: PyObject_CallObject code dump after calling 4 times

2008-01-03 Thread Phil Thompson
On Thursday 03 January 2008, grbgooglefan wrote: > I have a following C++ code which uses PyObject_CallObject to evaluate > expressions dynamically. This code sets the input parameters for the > function also dynamically. After calling this function 4 times (with > these shown values), PyObject_Cal

Re: PyObject_CallObject code dump after calling 4 times

2008-01-03 Thread Fredrik Lundh
grbgooglefan wrote: > I have a following C++ code which uses PyObject_CallObject to evaluate > expressions dynamically. This code sets the input parameters for the > function also dynamically. After calling this function 4 times (with > these shown values), PyObject_CallObject causes application

PyObject_CallObject code dump after calling 4 times

2008-01-03 Thread grbgooglefan
I have a following C++ code which uses PyObject_CallObject to evaluate expressions dynamically. This code sets the input parameters for the function also dynamically. After calling this function 4 times (with these shown values), PyObject_CallObject causes application to crash in frame_dealloc. 1)

  1   2   >