Re: segfault with small pyqt script

2010-08-13 Thread Gelonida
Lee, On 08/13/2010 12:53 AM, Lee Harr wrote: > >> I'm desperate. I'm having a real application, which fails rather often >> when finishing it. I'm not sure, whether any serious problem could be >> hidden behind it >> >> The script is a pyqt script, which segfaults most of the time on my >> ubuntu

How do I get number of files in a particular directory.

2010-08-13 Thread blur959
Hi, all, Is there a way to get a number of files in a particular directory? I tried using os.walk, os.listdir but they are return me with a list, tuple of the files, etc. But I want it to return a number. Is it possible? -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Bruno Desthuilliers
blur959 a écrit : Hi, all, Is there a way to get a number of files in a particular directory? I tried using os.walk, os.listdir but they are return me with a list, tuple of the files, etc. But I want it to return a number. Is it possible? len(any_sequence) -- http://mail.python.org/mailman/list

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Cameron Simpson
On 13Aug2010 00:54, blur959 wrote: | Hi, all, Is there a way to get a number of files in a particular | directory? I tried using os.walk, os.listdir but they are return me | with a list, tuple of the files, etc. But I want it to return a | number. Is it possible? Measure the length of the list re

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread Martin P. Hellwig
SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION On 08/12/10 21:41, News123 wrote: On 08/12/2010 09:56 PM, Martin P. Hellwig wrote: On 08/11/10 21:14, Baba wrote: How about rephrasing that question in your mind first, i.e.: For every number that is one higher then the previous one*:

Re: How do I get number of files in a particular directory.

2010-08-13 Thread blur959
Hi, I tried that, but it doesn't seem to work. My file directory has many different files extensions, and I want it to return me a number based on the number of files with similar files extensions. But when I tried running it, I get many weird numbers. Below is my code i had so far and the result.

Re: Importing libs on Windows?

2010-08-13 Thread Dave Angel
Brian Salter wrote: It appears that every example is calling a dll, and I'm looking to bring in a lib. Does ctypes work with libs too? "Gary Herron" wrote in message news:mailman.2044.1281656800.1673.python-l...@python.org... On 08/12/2010 04:09 PM, Brian Salter wrote: I've seen a number of

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Stefan Schwarzer
On 2010-08-13 11:18, blur959 wrote: > import os > > directory = raw_input("Please input file directory. \n\n") > s = raw_input("Please input a name to replace. \n\n") > ext = raw_input("input file ext") > > for files in os.listdir(directory): > if ext in files: > file_number = len(fil

writing \feff at the begining of a file

2010-08-13 Thread Jean-Michel Pichavant
Hello python world, I'm trying to update the content of a $Microsoft$ VC2005 project files using a python application. Since those files are XML data, I assumed I could easily do that. My problem is that VC somehow thinks that the file is corrupted and update the file like the following: -

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Peter Otten
Martin P. Hellwig wrote: > SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION > > On 08/12/10 21:41, News123 wrote: > >> On 08/12/2010 09:56 PM, Martin P. Hellwig wrote: >>> On 08/11/10 21:14, Baba wrote: >>> >>> >>> How about rephrasing that question in your mind first, i.e.: >>> >>> For ev

Re: writing \feff at the begining of a file

2010-08-13 Thread Tim Golden
On 13/08/2010 10:45, Jean-Michel Pichavant wrote: My problem is however simplier : how do I add such character at the begining of the file ? I tried f = open('paf', w) f = open ("pag", "wb") f.write ("\xfe\xff") TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Floating numbers

2010-08-13 Thread Mark Dickinson
On Aug 12, 9:43 pm, Bradley Hintze wrote: > Hi all. > > Is there a way I can keep my floating point number as I typed it? For > example, I want 34.52 to be 34.52 and NOT 34.520002. Nitpick: unless you're on very unusual hardware, you're missing some zeros here. On my machine, under Python 2.

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Roald de Vries
On Aug 12, 2010, at 10:51 PM, John Posner wrote: On 8/12/2010 9:22 AM, Dave Angel wrote: Now you have to find the largest number below 120, which you can easily do with brute force tgt = 120 # thanks, Dave Angel Anytime, but I'm not Dave Angel. My previous algorithm was more efficient, b

Deditor -- pythonic text-editor

2010-08-13 Thread Kruptein
Hey, I've finished my second version of deditor, a python text-editor for python under linux. It offers some python-only features like an interpreter, a code- analyzer, syntax-highlighting,... Are there some people in here who would like to test the app? (and maybe even help spread it) more info

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Roald de Vries
On Aug 13, 2010, at 12:25 PM, Roald de Vries wrote: My previous algorithm was more efficient, but for those who like one- liners: [x for x in range(120) if any(20*a+9*b+6*c == x for a in range(x/20) for b in range(x/9) for c in range(x/6))][-1] OK, I did some real testing now, and there's s

Python CGI windows

2010-08-13 Thread Srikanth N
Dear All, I Have certain clarification in python CGI. I use Python IDLE *1. How do we execute CGI Scripts in Windows? 2. How do i configure the Server?(If i use WAMP,XAMPP) 3. Is mod_python required for python cgi? * Someone Please revert back to me with the solution for the same.I would be at-m

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread Martin P. Hellwig
On 08/13/10 10:46, Peter Otten wrote: Martin P. Hellwig wrote: SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION No it wasn't :-) which should be 1*9 + 2*6 What am I missing? Aah interesting, 21 % 9 returns 3 instead of 12, which makes sense of course. I guess the algorithm has to b

Re: writing \feff at the begining of a file

2010-08-13 Thread Ulrich Eckhardt
Jean-Michel Pichavant wrote: > My problem is however simplier : how do I add such character [a BOM] > at the begining of the file ? > I tried > > f = open('paf', w) > f.write(u'\ufeff') > > UnicodeEncodeError: 'ascii' codec can't encode character u'\ufeff' in > position 0: ordinal not in range(12

Re: How do I get number of files in a particular directory.

2010-08-13 Thread blur959
On Aug 13, 6:09 pm, Peter Otten <__pete...@web.de> wrote: > blur959 wrote: > > Hi, I tried that, but it doesn't seem to work. My file directory has > > many different files extensions, and I want it to return me a number > > based on the number of files with similar files extensions. But when I > >

Re: Inserting/Deleting newline(s) in very large text files

2010-08-13 Thread Dlanor Slegov
I would greatly appreciate a python solution as this problem is only the head of a larger problem for which I am on a mission to write a FULL one-stop-shop python script. I am trying two things- iter() and fileinput module... Thanks! From: Matty Sarro To: Dlan

Embedding, subinterpreters and dynamic types

2010-08-13 Thread Mikael Liljeroth
Hi, this is my first contact with the python community so I hope this is the right place for my two questions. They are both related to embedding and extending python. I'm writing a program that dynamically loads c++ modules that extend the functionality of my program. These modules are controlled

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Peter Otten
blur959 wrote: > On Aug 13, 6:09 pm, Peter Otten <__pete...@web.de> wrote: >> blur959 wrote: >> > Hi, I tried that, but it doesn't seem to work. My file directory has >> > many different files extensions, and I want it to return me a number >> > based on the number of files with similar files exte

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Dave Angel
blur959 wrote: On Aug 13, 6:09 pm, Peter Otten <__pete...@web.de> wrote: blur959 wrote: Hi, I tried that, but it doesn't seem to work. My file directory has many different files extensions, and I want it to return me a number based on the number of files with similar files extensions. B

Re: Floating numbers

2010-08-13 Thread jmfauth
A quick question. I understand how to get these numbers 34.5231263880373081783294677734375 and 47 (from 2**47) and the sign. with the decimal module, but I fail to find this one 4858258098025923 Possible? -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get number of files in a particular directory.

2010-08-13 Thread blur959
Hi all, I got a problem with my script. Everything looks good so far but for some reason my os.rename isn't working. Can anyone tell me why? Hope you guys could help. Thanks. import os import glob directory = raw_input("directory? ") ext = raw_input("file extension? ") r = raw_input("replace na

Re: Python "why" questions

2010-08-13 Thread Den
> ... However, the killer reason is: "it's what everybody > else does. If this were really true, lists would be 1-based. I go back to WATFOR; and Fortran (and I believe Cobol and PL/I, though I'm not positive about them) were 1-based. (Now that I think about it, PL/I, knowing IBM, could probably

Re: Floating numbers

2010-08-13 Thread Mark Dickinson
On Aug 13, 3:03 pm, jmfauth wrote: > A quick question. > > I understand how to get these numbers > > 34.5231263880373081783294677734375 > > and > > 47 (from 2**47) > > and the sign. > > with the decimal module, but I fail to find this one > > 4858258098025923 > > Possible? See the

text to DB

2010-08-13 Thread Praveen
I have a text file in this format PRA 1:13 2:20 3:5 SRA 1:45 2:75 3:9 TRA 1:2 2:65 3:45 pattern is- Book Chapter:Verses now i have my DB schema like this book_id chapter_id versed_id 1 1 13 1 2 20 1 3

Re: Embedding, subinterpreters and dynamic types

2010-08-13 Thread Thomas Jollans
On 2010-08-13 13:22, Mikael Liljeroth wrote: > Hi, this is my first contact with the python community so I hope this > is the right place for my two questions. > They are both related to embedding and extending python. > > I'm writing a program that dynamically loads c++ modules that extend > the f

Re: python interview quuestions

2010-08-13 Thread Simon Brunning
On 11 August 2010 13:34:09 UTC+1, Steven D'Aprano wrote: > Getting interviewees to do a take-home problem just means you hire the > guy who is friends with a good programmer, rather than the good > programmer. We give a take-home problem. If we like the code we see, we invite the candidate to com

how to make portable distribution of python 2.6?

2010-08-13 Thread zaur
All greetings! How to make portable distribution of python 2.6? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python "why" questions

2010-08-13 Thread Thomas Jollans
On 2010-08-13 17:27, Den wrote: > There may be loads of reasons for it, but don't throw common sense > around as one of them. > It's a good thing then that I didn't: >> ... However, the killer reason is: "it's what everybody >> else does. >> > "Where it all started" is that 0-based index

Re: how to make portable distribution of python 2.6?

2010-08-13 Thread Thomas Jollans
On 2010-08-13 19:00, zaur wrote: > All greetings! > > How to make portable distribution of python 2.6? > I don't know, but what you're looking for probably already exists. Do you mean "portable" as in portable, i.e. "take this and build it for your system, it should work if your OS is supported

Re: Python CGI windows

2010-08-13 Thread Thomas Jollans
On 2010-08-13 12:40, Srikanth N wrote: > *1. How do we execute CGI Scripts in Windows? > * You'll need a web server. > *2. How do i configure the Server?(If i use WAMP,XAMPP) > * For CGI, you just need your server configured for CGI, nothing Python-specific. It would surprise me if XAMPP didn't se

Re: Python CGI windows

2010-08-13 Thread Thomas Jollans
On 2010-08-13 12:40, Srikanth N wrote: > *2. How do i configure the Server?(If i use WAMP,XAMPP) > * Sorry, I forgot to link you to http://www.editrocket.com/articles/python_apache_windows.html Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python "why" questions

2010-08-13 Thread Neil Cerutti
On 2010-08-13, Thomas Jollans wrote: > 1-based indexing might seam more intuitive, but in the end, > it's just another thing you have to learn when learning a > language, like "commas make tuples", and somebody studying a > programming language learns it, and gets used to it if they > aren't used

Re: writing \feff at the begining of a file

2010-08-13 Thread MRAB
Jean-Michel Pichavant wrote: Hello python world, I'm trying to update the content of a $Microsoft$ VC2005 project files using a python application. Since those files are XML data, I assumed I could easily do that. My problem is that VC somehow thinks that the file is corrupted and update the

Re: Python "why" questions

2010-08-13 Thread Martin Gregorie
On Fri, 13 Aug 2010 19:14:44 +0200, Thomas Jollans wrote: > "Where it all started" is that 0-based indexing gives languages like C a > very nice property: a[i] and *(a+i) are equivalent in C. From a language > design viewpoint, I think that's quite a strong argument. Languages > based directly on

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread MRAB
Martin P. Hellwig wrote: On 08/13/10 10:46, Peter Otten wrote: Martin P. Hellwig wrote: SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION No it wasn't :-) which should be 1*9 + 2*6 What am I missing? Aah interesting, 21 % 9 returns 3 instead of 12, which makes sense of course. I gu

Re: writing \feff at the begining of a file

2010-08-13 Thread Nobody
On Fri, 13 Aug 2010 11:45:28 +0200, Jean-Michel Pichavant wrote: > I'm trying to update the content of a $Microsoft$ VC2005 project files > using a python application. > Since those files are XML data, I assumed I could easily do that. > > My problem is that VC somehow thinks that the file is co

Re: text to DB

2010-08-13 Thread MRAB
Praveen wrote: I have a text file in this format PRA 1:13 2:20 3:5 SRA 1:45 2:75 3:9 TRA 1:2 2:65 3:45 pattern is- Book Chapter:Verses now i have my DB schema like this book_id chapter_id versed_id 1 1 13 1 2 20 1

Re: Python "why" questions

2010-08-13 Thread Lie Ryan
On 08/10/10 06:36, Bartc wrote: > And if the context is Python, I doubt whether the choice of 0-based over a > 1-based makes that much difference in execution speed. And I doubt anyone cares about execution speed when deciding whether to use 1-based or 0-based array. The reason why you want to ch

Re: Python "why" questions

2010-08-13 Thread Lie Ryan
Sorry the message gets cuts off by an accidental press of send button. On 08/14/10 04:31, Lie Ryan wrote: > On 08/10/10 06:36, Bartc wrote: >> And if the context is Python, I doubt whether the choice of 0-based over a >> 1-based makes that much difference in execution speed. > > And I doubt anyo

Re: how to make portable distribution of python 2.6?

2010-08-13 Thread zaur
On 13 авг, 21:28, Thomas Jollans wrote: > On 2010-08-13 19:00, zaur wrote:> All greetings! > > > How to make portable distribution of python 2.6? > > I don't know, but what you're looking for probably already exists. > > Do you mean "portable" as in portable, i.e. "take this and build it for > you

Python Tutorial

2010-08-13 Thread AK
Hello, I plan to make a new python tutorial and I'd like to collaborate with someone on it. I'm thinking of a slightly different approach than existing tutorials: the idea is that readers will learn from examples, going from small but complete and useful scripts to larger programs, similar to Dja

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Baba
Hi News 123, Ok i'm getting closer. I am able to write code that will output values that can be bought in exact quantity (truelist) and values that cannot be bought in exact quantities. For a range up to 29 i get this: true [6, 9, 12, 15, 18, 20, 21, 24, 26, 27, 29] false [0, 1, 2, 3, 4, 5, 7, 8,

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Baba
Hi News 123, Ok i'm getting closer. I am able to write code that will output values that can be bought in exact quantity (truelist) and values that cannot be bought in exact quantities. For a range up to 29 i get this: true [6, 9, 12, 15, 18, 20, 21, 24, 26, 27, 29] false [0, 1, 2, 3, 4, 5, 7, 8,

Re: Floating numbers

2010-08-13 Thread jmfauth
On 13 août, 17:43, Mark Dickinson wrote: > On Aug 13, 3:03 pm, jmfauth wrote: > > > > > A quick question. > > > I understand how to get these numbers > > > 34.5231263880373081783294677734375 > > > and > > > 47 (from 2**47) > > > and the sign. > > > with the decimal module, but I f

Re: cx_Oracle 5.0.4 + Python 3.1.2 + Oracle Instant Client 10.2.04; DLL Load failed on import (Win/NT)

2010-08-13 Thread Hans Mulder
tormod wrote: On Aug 12, 12:30 pm, Alexander Gattin wrote: Does Windows have anything like LD_LIBRARY_PATH/SHLIB_PATH? Yes and no. Windows uses PATH both for finding execuables and for finding DLLs. So if there's a DLL Windows cannot find, you need to add the folder containing that DLL to y

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread Ian Kelly
On Fri, Aug 13, 2010 at 12:25 PM, Baba wrote: > Hi News 123, > > Ok i'm getting closer. I am able to write code that will output values > that can be bought in exact quantity (truelist) and values that cannot > be bought in exact quantities. > > For a range up to 29 i get this: > true [6, 9, 12, 1

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Alister Ware
On Fri, 13 Aug 2010 07:40:42 -0700, blur959 wrote: > Hi all, I got a problem with my script. Everything looks good so far but > for some reason my os.rename isn't working. Can anyone tell me why? Hope > you guys could help. Thanks. > You have a number of logic flaws in your code. 1st you do not

struct pointing to another struct?

2010-08-13 Thread inhahe
say i have this definition: 1 typedef struct SDL_Surface { 2 Uint32 flags; /* Read-only */ 3 SDL_PixelFormat *format;/* Read-only */ 4 int w, h; /* Read-only */ 5 Uint16 pitch;

Re: struct pointing to another struct?

2010-08-13 Thread Peter Otten
inhahe wrote: > say i have this definition: > >1 typedef struct SDL_Surface { >2 Uint32 flags; /* Read-only */ >3 SDL_PixelFormat *format;/* Read-only */ >4 int w, h; /* Read-only */ >5 Uin

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread News123
Roald, What would your solution be if you weren't allowed to 'know' that 120 is an upper limit. Assume you were only allowed to 'know', that you won't find any other amount, which can't be bought A AOON A you found six solutions in a row? I have a rather straightforward solution trying from 0

Re: struct pointing to another struct?

2010-08-13 Thread inhahe
On Aug 13, 4:07 pm, Peter Otten <__pete...@web.de> wrote: > inhahe wrote: > > say i have this definition: > > >    1 typedef struct SDL_Surface { > >    2     Uint32 flags;                           /* Read-only */ > >    3     SDL_PixelFormat *format;                /* Read-only */ > >    4     in

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread John Posner
On 8/13/2010 6:25 AM, Roald de Vries wrote: On Aug 12, 2010, at 10:51 PM, John Posner wrote: On 8/12/2010 9:22 AM, Dave Angel wrote: Now you have to find the largest number below 120, which you can easily do with brute force tgt = 120 # thanks, Dave Angel Anytime, but I'm not Dave Angel.

Dump logging configuration

2010-08-13 Thread Kxepal
Hi all! Sorry for dumb question if it is - I'd tried to google it before but have found nothing. Is there any way to dump current logging configuration for future loading it via fileConfig/dictConfig? -- http://mail.python.org/mailman/listinfo/python-list

Help to convert Number to String

2010-08-13 Thread Vamsi
I am trying to count the number of lines in a file and insert into the file but getting the error message "TypeError: must be string or read-only character buffer, not int", Could you please help me how to correct this? here is the code lines1 = sum(1 for line in open('C:/test1.txt')) wfile = o

Re: looping through possible combinations of McNuggets packs of 6,9 and 20

2010-08-13 Thread News123
On 08/13/2010 10:57 AM, Martin P. Hellwig wrote: > SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION > > On 08/12/10 21:41, News123 wrote: > >> On 08/12/2010 09:56 PM, Martin P. Hellwig wrote: >>> On 08/11/10 21:14, Baba wrote: >>> >>> >>> How about rephrasing that question in your mind firs

Re: struct pointing to another struct?

2010-08-13 Thread Peter Otten
inhahe wrote: > On Aug 13, 4:07 pm, Peter Otten <__pete...@web.de> wrote: >> inhahe wrote: >> > say i have this definition: >> >> > 1 typedef struct SDL_Surface { >> > 2 Uint32 flags; /* Read-only */ >> > 3 SDL_PixelFormat *format;/* Read-only */ >

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-13 Thread News123
Hi BAba, On 08/13/2010 09:25 PM, Ian Kelly wrote: > On Fri, Aug 13, 2010 at 12:25 PM, Baba wrote: >> Hi News 123, >> >> Ok i'm getting closer. I am able to write code that will output values >> that can be bought in exact quantity (truelist) and values that cannot >> be bought in exact quantitie

Re: segfault with small pyqt script

2010-08-13 Thread Gelonida
On 08/13/2010 09:11 AM, Gelonida wrote: > Lee, > > On 08/13/2010 12:53 AM, Lee Harr wrote: >> >>> I'm desperate. I'm having a real application, which fails rather often >>> when finishing it. I'm not sure, whether any serious problem could be >>> hidden behind it >>> >>> The script is a pyqt scrip

Re: shelf-like list?

2010-08-13 Thread Raymond Hettinger
On Aug 12, 1:37 pm, Thomas Jollans wrote: > On Tuesday 10 August 2010, it occurred to kj to exclaim: > > > I'm looking for a module that implements "persistent lists": objects > > that behave like lists except that all their elements are stored > > on disk.  IOW, the equivalent of "shelves", but f

Re: segfault with small pyqt script

2010-08-13 Thread Gelonida
On 08/13/2010 09:11 AM, Gelonida wrote: > Lee, > > On 08/13/2010 12:53 AM, Lee Harr wrote: >> >>> I'm desperate. I'm having a real application, which fails rather often >>> when finishing it. I'm not sure, whether any serious problem could be >>> hidden behind it >>> >>> The script is a pyqt scrip

math symbols in unicode (grouped by purpose)

2010-08-13 Thread Xah Lee
some collection of math symbols in unicode. • Math Symbols in Unicode http://xahlee.org/comp/unicode_math_operators.html • Arrows in Unicode http://xahlee.org/comp/unicode_arrows.html • Matching Brackets in Unicode http://xahlee.org/comp/unicode_matching_brackets.html these are grouped by

Re: Floating numbers

2010-08-13 Thread Aahz
In article <595969e7-354f-456d-82b5-6aeafbabe...@d8g2000yqf.googlegroups.com>, Mark Dickinson wrote: > > - If you *really* need a number that represents the *exact* value >34.52, then use the decimal module, or perhaps consider using a simple >home-brewed fixed-point representation. Don't use

Re: Python "why" questions

2010-08-13 Thread Terry Reedy
On 8/13/2010 11:27 AM, Den wrote: I smile every time I see the non-nonsensical sentence "The first thing, therefore, is in thing[0]" in a programming language learning book or tutorial. I laugh every time I hear someone defend that as common sense. If one thinks in terms of slicing at gap po

Re: EXOR or symmetric difference for the Counter class

2010-08-13 Thread Paddy
On Aug 13, 6:36 am, Steven D'Aprano wrote: > On Thu, 12 Aug 2010 13:20:19 -0700, Paddy wrote: > > I find myself needing to calculate the difference between two Counters > > or multisets or bags. > > Is this collections.Counter from Python 3.1? If so, you should say so, > and if not, you should tel

Re: writing \feff at the begining of a file

2010-08-13 Thread Terry Reedy
A short background to MRAB's answer which I will try to get right. The byte-order-mark was invented for UTF-16 encodings so the reader could determine whether the pairs of bytes are in little or big endiean order, depending on whether the first two bute are fe and ff or ff and fe (or maybe vic

Re: Python "why" questions

2010-08-13 Thread Ian Kelly
On Fri, Aug 13, 2010 at 11:53 AM, Martin Gregorie wrote: > In a higher level language 1-based indexing is just as limiting as 0- > based indexing. What you really want is the ability to declare the index > range to suit the problem: in Algol 60 it is very useful to be able to > declare something l

Re: Help to convert Number to String

2010-08-13 Thread Stefan Schwarzer
Hi Vamsi, On 2010-08-13 22:50, Vamsi wrote: > I am trying to count the number of lines in a file and insert into > the file but getting the error message "TypeError: must be string or > read-only character buffer, not int", Could you please help me how to > correct this? Which Python version do

Simple Python Sandbox

2010-08-13 Thread Stephen Hansen
Howdy-ho. So, I'm working on a project which embeds Python into a bigger system to provide extensibility. In this project, there's basically two types of people who will be entering python code. The trusted folks, who write code which are in files, and which can do anything. The untrusted folks,

Re: Simple Python Sandbox

2010-08-13 Thread geremy condra
On Fri, Aug 13, 2010 at 4:37 PM, Stephen Hansen wrote: > Howdy-ho. > > So, I'm working on a project which embeds Python into a bigger system to > provide extensibility. In this project, there's basically two types of > people who will be entering python code. > > The trusted folks, who write code

Re: Simple Python Sandbox

2010-08-13 Thread Stephen Hansen
On 8/13/10 4:57 PM, geremy condra wrote: > You may want to check out repy- they use it in the Seattle restricted > execution environment, and some pretty smart people claim it has > decent security properties. Here's a summary of some of the things > they don't allow: > > https://seattle.cs.washin

Re: Help to convert Number to String

2010-08-13 Thread Steven D'Aprano
On Fri, 13 Aug 2010 13:50:48 -0700, Vamsi wrote: > I am trying to count the number of lines in a file and insert into the > file but getting the error message "TypeError: must be string or > read-only character buffer, not int", Could you please help me how to > correct this? > > > here is the

Re: writing \feff at the begining of a file

2010-08-13 Thread Steven D'Aprano
On Fri, 13 Aug 2010 18:25:46 -0400, Terry Reedy wrote: > A short background to MRAB's answer which I will try to get right. > > The byte-order-mark was invented for UTF-16 encodings so the reader > could determine whether the pairs of bytes are in little or big endiean > order, depending on wheth

Re: Help to convert Number to String

2010-08-13 Thread Vamsi
On Aug 13, 7:27 pm, Stefan Schwarzer wrote: > Hi Vamsi, > > On 2010-08-13 22:50, Vamsi wrote: > > > I am trying to count the number of lines in a file and insert  into > > the file but getting the error message "TypeError: must be string or > > read-only character buffer, not int", Could you pleas

Re: Help to convert Number to String

2010-08-13 Thread Vamsi
On Aug 13, 9:06 pm, Steven D'Aprano wrote: > On Fri, 13 Aug 2010 13:50:48 -0700, Vamsi wrote: > > I am trying to count the number of lines in a file and insert  into the > > file but getting the error message "TypeError: must be string or > > read-only character buffer, not int", Could you please

Re: Simple Python Sandbox

2010-08-13 Thread Steven D'Aprano
On Fri, 13 Aug 2010 16:37:40 -0700, Stephen Hansen wrote: > Howdy-ho. > > So, I'm working on a project which embeds Python into a bigger system to > provide extensibility. In this project, there's basically two types of > people who will be entering python code. > > The trusted folks, who write

Re: Help to convert Number to String

2010-08-13 Thread Ben Finney
Vamsi writes: > fileopen = open('C:/MPython/test.txt', 'r') > str = fileopen.read() The above statement clobbers the existing binding of ‘str’ to the built-in string type. From that point on, the built-in string type is no longer accessible by the name ‘str’; that name accesses a different objec

minidom help -- line number

2010-08-13 Thread GZ
Hi All, I am writing a little program that reads the minidom tree built from an xml file. I would like to print out the line number of the xml file on the parts of the tree that are not valid. But I do not seem to find a way to correspond minidom nodes to line numbers. Can anyone give me some hel