errors and exception

2010-08-16 Thread Alan
Hello, I am using things like: except Exception as inst: and with open("myfile.txt") as f: for line in f: print line Things that seems to be new in python 2.6 and higher, however reading http://docs.python.org/tutorial/errors.html and this not clear when this new syntaxes appeared.

Re: Working with PDFs?

2010-08-16 Thread MRAB
jyoun...@kc.rr.com wrote: Just curious if anyone knows if it's possible to work with pdf documents with Python? I'd like to do the following: - Pull out text from each PDF page (to search for specific words) - Combine separate pdf documents into one document - Add bookmarks (with destination s

Re: segfault with small pyqt script

2010-08-16 Thread Gelonida
Hi Hans-Peter, It seems, that my other posts did not get through. On 08/15/2010 11:17 PM, Hans-Peter Jansen wrote: > For a starter, tell us the versions of python-sip, and python-qt4 or however > they're called in Ubuntu. For the record, > python-sip-4.10.5-1.1 > python-qt4-4.7.4-1.1 > doesn't

[Q] How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
[Q] How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ? Because a stack has push and pop, it is able to release and allocate memory. We envisage an exogenous stack which has malloc() associated with a push and free() associated with a pop. The algorithm using

Re: errors and exception

2010-08-16 Thread Gary Herron
On 08/16/2010 12:06 AM, Alan wrote: Hello, I am using things like: except Exception as inst: and The old syntax for exceptions still works in Python2.x (all versions). The new syntax works in Python2.6+ and Python3. try: whatever except Exception,msg: # Old syntax

Re: [Q] How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Alf P. Steinbach /Usenet
* Standish P, on 16.08.2010 09:20: [garble garble] Nonsense article "We look for an exogenous stack" cross-posted to [comp.lang.c], [comp.lang.c++], [comp.theory], [comp.lang.python], [comp.lang.forth]. Please refrain from following up on Standish' article. Cheers, - Alf -- blog

Re: [Q] How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Stefan Behnel
Standish P, 16.08.2010 09:20: We envisage an exogenous stack which has malloc() associated with a push and free() associated with a pop. What's your use case? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: errors and exception

2010-08-16 Thread Daniel Urban
> f = open("myfile.txt") > for line in f: >   print line > f.close()   # This is what the "with" statement guarantees; so now just do > it yourself Not exactly. More like: f = open("myfile.txt") try: for line in f: print line finally: f.close() Daniel -- http://mail.python.org/

Re: errors and exception

2010-08-16 Thread Chris Rebert
On Mon, Aug 16, 2010 at 12:29 AM, Gary Herron wrote: > On 08/16/2010 12:06 AM, Alan wrote: >> Hello, >> I am using things like: >> with open("myfile.txt") as f: >> for line in f: >> print line > > You don't need the new fangled with statement if you want to be compatible > with older

Re: Replace and inserting strings within .txt files with the use of regex

2010-08-16 Thread Νίκος
On 10 Αύγ, 01:43, MRAB wrote: > Íßêïò wrote: > > D:\>convert.py > >   File "D:\convert.py", line 34 > > SyntaxError: Non-ASCII character '\xce' in file D:\convert.py on line > > 34, but no > >  encoding declared; seehttp://www.python.org/peps/pep-0263.htmlfor > > details > > > D:\> > > > What does

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Nick Keighley
this is heavily x-posted I'm answering from comp.lang.c On 16 Aug, 08:20, Standish P wrote: > [Q] How far can stack [LIFO] solve do automatic garbage collection and > prevent memory leak ? I'm having trouble understanding your question (I read your whole post before replying). I strongly suspec

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

2010-08-16 Thread Roald de Vries
On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote: On Sun, Aug 15, 2010 at 4:36 PM, Baba wrote: Hi Mel, indeed i thought of generalising the theorem as follows: If it is possible to buy n, n+1,…, n+(x-1) sets of McNuggets, for some x, then it is possible to buy any number of McNuggets >= x, give

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
On Aug 16, 12:47 am, Nick Keighley wrote: > this is heavily x-posted I'm answering from comp.lang.c > > On 16 Aug, 08:20, Standish P wrote: > > > [Q] How far can stack [LIFO] solve do automatic garbage collection and > > prevent memory leak ? > > I'm having trouble understanding your question (I

comp.lang.python

2010-08-16 Thread roshini begum
www.127760.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Kruptein
I still keep getting more downloads then usual which is awesome, but I still don't get any kind of response! please mail me or reply to this post with what you think, You can tell me that the program sucks but if you want to, do it in such a way that you also describe what exactly is the problem an

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Nick Keighley
On 16 Aug, 09:33, Standish P wrote: > On Aug 16, 12:47 am, Nick Keighley > > On 16 Aug, 08:20, Standish P wrote: this is heavily x-posted I'm answering from comp.lang.c I also note that another poster has suggested you are a troll/loon you seem to be using some computer science-like terms but

When the first line of a file tells something about the other lines

2010-08-16 Thread Egbert Bouwman
Often the first line of a file tells how to read or interpret the other lines. Depending on the result, you then have to ... - skip the first line, or - treat the first line in another special way, or - treat the first line in the same way as the other lines. I can handle this by opening the file

GSM to ISO / UCS2 to ISO

2010-08-16 Thread James Mills
HI all, In an effort to avoid re-inventing the wheel so to speak I was wondering if anyone's come across libraries/tools, etc that achieve the same kind of functionality as the tools library in this java app. http://code.google.com/p/ipddump/source/browse/trunk/src/ipddump/tools/Gsm2Iso.java Tha

Re: When the first line of a file tells something about the other lines

2010-08-16 Thread Peter Otten
Egbert Bouwman wrote: > Often the first line of a file tells how to read or interpret the other > lines. > Depending on the result, you then have to ... > - skip the first line, or > - treat the first line in another special way, or > - treat the first line in the same way as the other lines. > >

Re: Python XML and tables using math

2010-08-16 Thread flebber
On Aug 16, 4:00 pm, Stefan Behnel wrote: > flebber, 16.08.2010 05:30: > > > I am looking at a project that will import and modify an XML file and > > then export it to a table. Currently a flat file table system should > > be fine. > > > I want to export the modified data to the table and then per

Re: text to DB

2010-08-16 Thread Praveen
On Aug 14, 11:15 am, Dennis Lee Bieber wrote: > On Fri, 13 Aug 2010 09:46:34 -0700 (PDT), Praveen > declaimed the following in > gmane.comp.python.general: > > > 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:Vers

Comparing lists

2010-08-16 Thread Francesco Bochicchio
Hi all, anybody can point me to a description of how the default comparison of list objects (or other iterables) works? Apparently l1 < l2 is equivalent to all ( x < y for x,y in zip( l1, l2) ), has is shown in the following tests, but I can't find it described anywhere: >>> [1,2,3] < [1,3,2

Problem checking an existing browser cookie

2010-08-16 Thread Νίκος
# initialize cookie cookie = Cookie.SimpleCookie() cookie.load( os.environ.get('HTTP_COOKIE', '') ) mycookie = cookie.get('visitor') if ( mycookie and mycookie.value != 'nikos' ) or re.search( r'(cyta| yandex|13448|spider|crawl)', host ) is None: blabla... I checked a

MS Word Document to html conversion

2010-08-16 Thread srinivas hn
Hi, I am working on application where it requires uploaded document from has to be converted to the html pages.Am searching for the suitable python package i dint found any thing apart from word2html.py.But the word2html.py is not available for download anywhere can any one suggest me how to solve

Re: Comparing lists

2010-08-16 Thread eliasf
On Mon, 16 Aug 2010 13:46:07 +0300, Francesco Bochicchio wrote: anybody can point me to a description of how the default comparison of list objects (or other iterables) works? Sequences of the same type are compared using lexicographical ordering: http://docs.python.org/tutorial/datastructur

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 01:52:52 -0700, Kruptein wrote: > I still keep getting more downloads then usual which is awesome, but I > still don't get any kind of response! Welcome to the real world. For every user who sends you an email, you'll probably have 1000 who don't. Or 10,000. > please mail

Re: Python "why" questions

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 16:28:46 +1200, Lawrence D'Oliveiro wrote: > In message <8crg0effb...@mid.individual.net>, Gregory Ewing wrote: > >> For example, the constant term of a polynomial is usually called term >> 0, not term 1. > > That is not some kind of ordinal numbering of the terms, that is th

Re: Pop return from stack?

2010-08-16 Thread Steven D'Aprano
On Sun, 15 Aug 2010 21:01:04 -0700, Carey Tilden wrote: > On Sun, Aug 15, 2010 at 6:43 PM, bvdp wrote: > >> Not to belabor the point .. but "func" is not a standard lib module. >> It's part of a much larger application ... and in that application it >> makes perfect sense to terminate the applic

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Malcolm McLean
On Aug 16, 10:20 am, Standish P wrote: > [Q] How far can stack [LIFO] solve do automatic garbage collection and > prevent memory leak ? > Most programs can be written so that most of their memory allocations are matched by destructors at the same level. However the allocations that can't be writt

Re: Comparing lists

2010-08-16 Thread Peter Otten
Francesco Bochicchio wrote: > Hi all, > > anybody can point me to a description of how the default comparison of > list objects (or other iterables) works? > > Apparently l1 < l2 is equivalent to all ( x < y for x,y in > zip( l1, l2) ), has is shown in the following tests, but I can't find >

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Steven D'Aprano
On Sun, 15 Aug 2010 17:36:07 -0700, Alex Willmer wrote: > On Aug 16, 1:07 am, Steven D'Aprano cybersource.com.au> wrote: >> You're passing re.IGNORECASE (which happens to equal 2) as a count >> argument, not as a flag. Try this instead: >> >> >>> re.sub(r"python\d\d" + '(?i)', "Python27", t) >> '

Re: Python "why" questions

2010-08-16 Thread Martin Gregorie
On Mon, 16 Aug 2010 12:33:51 +1200, Gregory Ewing wrote: > Ian Kelly wrote: >> On Fri, Aug 13, 2010 at 11:53 AM, Martin Gregorie >> wrote: > >>> real sample[-500:750]; > >> Ugh, no. The ability to change the minimum index is evil. > > Not always; it can have its uses, particularly when

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Peter Otten
Steven D'Aprano wrote: > On Mon, 16 Aug 2010 01:52:52 -0700, Kruptein wrote: > >> I still keep getting more downloads then usual which is awesome, but I >> still don't get any kind of response! > > Welcome to the real world. For every user who sends you an email, you'll > probably have 1000 who

Re: Problem checking an existing browser cookie

2010-08-16 Thread Peter Otten
Νίκος wrote: > # initialize cookie > cookie = Cookie.SimpleCookie() > cookie.load( os.environ.get('HTTP_COOKIE', '') ) > mycookie = cookie.get('visitor') > > if ( mycookie and mycookie.value != 'nikos' ) or re.search( r'(cyta| > yandex|13448|spider|crawl)', host ) is None: > blabla... > =

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Christopher
On Aug 15, 8:07 pm, Steven D'Aprano wrote: > On Sun, 15 Aug 2010 16:45:49 -0700, Christopher wrote: > > I have the following problem: > > t="Python26" > import re > re.sub(r"python\d\d", "Python27", t) > > 'Python26' > re.sub(r"python\d\d", "Python27", t, re.IGNORECASE) > > 'Py

Re: Pop return from stack?

2010-08-16 Thread Steven D'Aprano
On Sun, 15 Aug 2010 18:43:49 -0700, bvdp wrote: [...] > However, I have gotten hit with more than one comment like yours. So, > could you please clarify? Is it bad form to exit an application with > sys.exit(1) when an error in a file the application is processing is > found? My two cents worth..

Re: Dump logging configuration

2010-08-16 Thread Jean-Michel Pichavant
Kxepal wrote: 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? I may be wrong but I don't think so. JM -- http://mail.python.org/mailman/li

Re: Python "why" questions

2010-08-16 Thread David Cournapeau
On Mon, Aug 16, 2010 at 9:53 AM, Gregory Ewing wrote: >> On Aug 7, 2010, at 9:14 PM, John Nagle wrote: >> >>>  The languages which have real multidimensional arrays, rather >>> than arrays of arrays, tend to use 1-based subscripts.  That >>> reflects standard practice in mathematics. > > Not alway

Textvariable display in label (GUI design)

2010-08-16 Thread Jah_Alarm
hi, pls help me out with the following issue: I wrote a function that uses a for loop that changes a value of a certain variable each iteration. What I want is by clicking a button in GUI (with the command bound to this function) this value each iteration is displayed in a textbox (label). So far

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread spinoza1111
On Aug 16, 3:20 pm, Standish P wrote: > [Q] How far can stack [LIFO] solve do automatic garbage collection and > prevent memory leak ? > > Because a stack has push and pop, it is able to release and allocate > memory. We envisage an exogenous stack which has malloc() associated > with a push and f

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread spinoza1111
On Aug 16, 7:20 pm, Malcolm McLean wrote: > On Aug 16, 10:20 am, Standish P wrote:> [Q] How far can > stack [LIFO] solve do automatic garbage collection and > > prevent memory leak ? > > Most programs can be written so that most of their memory allocations > are matched by destructors at the sam

Re: Deditor -- pythonic text-editor

2010-08-16 Thread eliasf
On Mon, 16 Aug 2010 14:26:09 +0300, Peter Otten <__pete...@web.de> wrote: Steven D'Aprano wrote: If nobody asks for any changes, then just keep doing what you're doing. Or you can introduce a bug; if your users don't start complaining you don't have any... Even that doesn't work. They may blo

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Alex Willmer
On Aug 16, 12:23 pm, Steven D'Aprano wrote: > On Sun, 15 Aug 2010 17:36:07 -0700, Alex Willmer wrote: > > On Aug 16, 1:07 am, Steven D'Aprano > cybersource.com.au> wrote: > >> You're passing re.IGNORECASE (which happens to equal 2) as a count > >> argument, not as a flag. Try this instead: > > >>

Re: Python "why" questions

2010-08-16 Thread Neil Cerutti
On 2010-08-15, John Nagle wrote: > In retrospect, C's "pointer=array" concept was a terrible > mistake. C arrays are not pointers. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Alex Willmer
On Aug 16, 1:46 pm, Alex Willmer wrote: > "Note that the (?x) flag changes how the expression is parsed. It > should be used first in the expression string, or after one or more > whitespace characters. If there are non-whitespace characters before > the flag, the results are undefined. > "http://

Re: Simple Python Sandbox

2010-08-16 Thread Roland Koebler
On Sat, Aug 14, 2010 at 07:54:11PM -0700, Stephen Hansen wrote: > How are you implementing refusing-names-beginning-with-underscore, out > of curiosity? I compile the expressions and look into co_names, e.g.: >>> expr = "0 .__class__" >>> c=compile(expr,"","eval") >>> c.co_names ('__class__

About UpdateLayeredWindow

2010-08-16 Thread Alexandru Ionescu
Hello, In the last two weeks I've been trying to properly use UpdateLayeredWindow in Python but I'm only getting errors. I searched a lot on the internet and you are the only person who posted about using ULW in Python. I tried with ctypes and I also tried with win32gui & win32api. I got all k

passing variables as object attributes

2010-08-16 Thread Vikas Mahajan
Hello to all I am new to python. I am facing problem to use variables as object attributes. I have to use loop and dynamically add attributes to a object and for this purpose I have to use variables with object names. For example-: Let us say object car has an attribute engine, then varname = "en

Re: passing variables as object attributes

2010-08-16 Thread Nitin Pawar
you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer On Mon, Aug 16, 2010 at 7:10 PM, Vikas Mahajan wrote: > Hello to all > > I am new to python. I am facing problem to use variables as object > attributes.

Re: When the first line of a file tells something about the other lines

2010-08-16 Thread egbert
On Mon, Aug 16, 2010 at 11:59:57AM +0200, Peter Otten wrote: > > with open(filename) as lines: > first_line = next(lines, "") > if special(first_line): > # ... > else: > lines = itertools.chain([first_line], lines) > for line in lines: > # ... Beautiful. An

Re: passing variables as object attributes

2010-08-16 Thread Vikas Mahajan
On 16 August 2010 19:23, Nitin Pawar wrote: > you would need to define a class first with its attiributes and then you may > want to initiate the variables by calling the class initilializer > Actually I have to dynamically add attributes to a object. I am writing python script for FreeCAD softwa

does someone has a binary 32-bit windows installer for arac ?

2010-08-16 Thread Stef Mientki
thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list

Re: passing variables as object attributes

2010-08-16 Thread nn
On Aug 16, 10:08 am, Vikas Mahajan wrote: > On 16 August 2010 19:23, Nitin Pawar wrote:> you > would need to define a class first with its attiributes and then you may > > want to initiate the variables by calling the class initilializer > > Actually I have to dynamically add attributes to a obj

Re: passing variables as object attributes

2010-08-16 Thread nn
On Aug 16, 10:08 am, Vikas Mahajan wrote: > On 16 August 2010 19:23, Nitin Pawar wrote:> you > would need to define a class first with its attiributes and then you may > > want to initiate the variables by calling the class initilializer > > Actually I have to dynamically add attributes to a obj

how to switch image in tkinter? making it mutable? how?

2010-08-16 Thread ChrisChia
I have this: image1 = ImageTk.PhotoImage(file = "c:\\f1.jpg") image2 = ImageTk.PhotoImage(file = "c:\\f2.jpg") imagelist.append(image1) imagelist.append(image2) self.label = tk.Label(image = imagelist[0]) is there a way that i can create a method to switch the display the image2 (imagelist 2nd

Re: Dump logging configuration

2010-08-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Kxepal wrote: 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? I may be wrong but I don't think so. JM Please

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread jacko
> is it possible to convert any and all algorithms to stack based ones and thus > avoid memory leaks? No, not really. If you keep the allocated things and free them in reverse order on exit, then well yes, but practically, early free() frees memory for reuse on low memory systems. In this sense n

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

2010-08-16 Thread Ian Kelly
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries wrote: >> I suspect that there exists a largest unpurchasable quantity iff at >> least two of the pack quantities are relatively prime, but I have made >> no attempt to prove this. > > That for sure is not correct; packs of 2, 4 and 7 do have a large

question about pdb assignment statements

2010-08-16 Thread Steve Ferg
In this little script: import pdb pdb.set_trace() def main(): xm = 123 print("Hello,world!") main() When I run this, I use pdb to step through it until I reach the point in main() where the xm variable has been initialized, and then I try to use pdb to reset the value of xm, and

Re: how to switch image in tkinter? making it mutable? how?

2010-08-16 Thread Eric Brunel
In article <414ff6dd-73ef-48df-bd2b-080a2c710...@h17g2000pri.googlegroups.com>, ChrisChia wrote: > I have this: > image1 = ImageTk.PhotoImage(file = "c:\\f1.jpg") > image2 = ImageTk.PhotoImage(file = "c:\\f2.jpg") > > imagelist.append(image1) > imagelist.append(image2) > > self.label = tk.La

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Malcolm McLean
On Aug 16, 3:14 pm, spinoza wrote: > > To build an explicit stack in this program would have been folly, for > it would have been necessary to either preallocate the stack and thus > legislate the maximum complexity of source code, or use a lot of > memory management in the pre-existing runtim

Re: Textvariable display in label (GUI design)

2010-08-16 Thread Eric Brunel
In article <993d9560-564d-47f0-b2db-6f0c6404a...@g6g2000pro.googlegroups.com>, Jah_Alarm wrote: > hi, > > pls help me out with the following issue: I wrote a function that uses > a for loop that changes a value of a certain variable each iteration. > What I want is by clicking a button in GUI

Re: passing variables as object attributes

2010-08-16 Thread misterdi
On Aug 16, 8:40 pm, Vikas Mahajan wrote: > Hello to all > > I am new to python. I am facing problem to use variables as object > attributes. I have to use loop and dynamically add attributes to a > object and for this purpose I have to use variables with object names. > > For example-: > Let us sa

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

2010-08-16 Thread Ian Kelly
On Mon, Aug 16, 2010 at 11:04 AM, Ian Kelly wrote: > On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries wrote: >>> I suspect that there exists a largest unpurchasable quantity iff at >>> least two of the pack quantities are relatively prime, but I have made >>> no attempt to prove this. >> >> That f

Re: Dump logging configuration

2010-08-16 Thread Kxepal
On Aug 16, 6:53 pm, Jean-Michel Pichavant wrote: > Jean-Michel Pichavant wrote: > > Kxepal wrote: > >> Hi all! > >> Sorry for dumb question if it is - I'd tried to google it before but > >> have found nothing. > > >> Is there any way todumpcurrentloggingconfiguration for future > >> loading it via

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Kruptein
on steven, peter and eliasf: Well okay I'm new to the world of developing programs, if I encounter problems I directly post a bug on the relevant page, that's maybe why I was a bit frustrated :) but what you three say is indeed true.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pop return from stack?

2010-08-16 Thread Carey Tilden
On Mon, Aug 16, 2010 at 4:18 AM, Steven D'Aprano wrote: > > On Sun, 15 Aug 2010 21:01:04 -0700, Carey Tilden wrote: > >> On Sun, Aug 15, 2010 at 6:43 PM, bvdp wrote: >> >>> Not to belabor the point .. but "func" is not a standard lib module. >>> It's part of a much larger application ... and in t

Re: passing variables as object attributes

2010-08-16 Thread Jean-Michel Pichavant
Vikas Mahajan wrote: On 16 August 2010 19:23, Nitin Pawar wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I have to dynamically add attributes to a object. I am writing pytho

Re: Opposite of split

2010-08-16 Thread Alex van der Spek
Thanks much, Nope, no homework. This was a serious question from a serious but perhaps simple physicist who grew up with Algol, FORTRAN and Pascal, taught himself VB(A) and is looking for a replacement of VB and finding that in Python. You can guess my age now. Most of my work I do in R nowa

EOFError with fileinput

2010-08-16 Thread Alex van der Spek
Using the fileinput module to process lists of files: for line in fileinput.input(logs): Unfortunately, EOFError does not seem to indicate the end-of-file condition correctly when using fileinput. How would you find the EOF file for all the files in the file list 'logs'? Thank you, Alex va

Re: python strings and {} in Tkinter entry widgets

2010-08-16 Thread Jeff Hobbs
On Aug 15, 4:41 pm, Chris Hare wrote: > I have some code that pulls a value from a database.  In this case, it is > three space delimited words.  When I display the value in a Tkinter.Entry > widget, the text has curly braces around it, even when there are none in the > surrounding the text in

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

2010-08-16 Thread Roald de Vries
On Aug 16, 2010, at 5:04 PM, Ian Kelly wrote: On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries wrote: I suspect that there exists a largest unpurchasable quantity iff at least two of the pack quantities are relatively prime, but I have made no attempt to prove this. That for sure is not co

Re: Opposite of split

2010-08-16 Thread Alex van der Spek
Perhaps the ones here who think I was trying to make you do my homework can actually help me for real. Since I run my own company (not working for any of the big ones) I can't afford official training in anything. So I teach myself, help is always welcome and sought for. If that feels like doing

Newbie: strftime object error message

2010-08-16 Thread fuglyducky
I am trying to call a function with a couple additional parameters. Unfortunately, for whatever reason I am unable to get this to work. I am assuming that line is not passing correctly but I don't understand why??? I can't share all of the code because it has IP in it but below are the pertinent s

Re: EOFError with fileinput

2010-08-16 Thread Mark Lawrence
On 16/08/2010 17:29, Alex van der Spek wrote: Using the fileinput module to process lists of files: for line in fileinput.input(logs): Unfortunately, EOFError does not seem to indicate the end-of-file condition correctly when using fileinput. How would you find the EOF file for all the files

Re: how to switch image in tkinter? making it mutable? how?

2010-08-16 Thread Jeff Hobbs
On Aug 16, 7:30 am, ChrisChia wrote: > I have this: > image1 = ImageTk.PhotoImage(file = "c:\\f1.jpg") > image2 = ImageTk.PhotoImage(file = "c:\\f2.jpg") > > imagelist.append(image1) > imagelist.append(image2) > > self.label  = tk.Label(image = imagelist[0]) > > is there a way that i can create a

Re: Opposite of split

2010-08-16 Thread D'Arcy J.M. Cain
On Mon, 16 Aug 2010 18:26:46 +0200 "Alex van der Spek" wrote: > Nope, no homework. This was a serious question from a serious but perhaps > simple physicist who grew up with Algol, FORTRAN and Pascal, taught himself > VB(A) and is looking for a replacement of VB and finding that in Python. You

Re: passing variables as object attributes

2010-08-16 Thread Vikas Mahajan
@All Thanks a lot. getattr and setattr functions solved my problem. -- http://mail.python.org/mailman/listinfo/python-list

How to convert bytearray into integer?

2010-08-16 Thread Jacky
Hi there, Recently I'm facing a problem to convert 4 bytes on an bytearray into an 32-bit integer. So far as I can see, there're 3 ways: a) using struct module, b) using ctypes module, and c) manually manipulation. Are there any other ways? My sample is as following: - import struct import

Re: python strings and {} in Tkinter entry widgets

2010-08-16 Thread Chris Hare
On Aug 16, 2010, at 11:40 AM, Jeff Hobbs wrote: > On Aug 15, 4:41 pm, Chris Hare wrote: >> I have some code that pulls a value from a database. In this case, it is >> three space delimited words. When I display the value in a Tkinter.Entry >> widget, the text has curly braces around it, even

Re: Opposite of split

2010-08-16 Thread D'Arcy J.M. Cain
On Mon, 16 Aug 2010 18:44:08 +0200 "Alex van der Spek" wrote: > Perhaps the ones here who think I was trying to make you do my homework can You keep replying to my message but as I pointed out in my previous message, I'm not the one who thought that you posted a homework question. I'm the one w

How can I bundle a PyGTK program in windows so my users don't need to install Python or the GTK+ libs?

2010-08-16 Thread Waspinator
I found this question on http://faq.pygtk.org/index.py?file=faq21.005.htp&req=show but the answer did not help me. For example I have a simple program below that I would like to 'compile' with py2exe (or anything else if it's simpler) to run in windows as a single bundled executable file with no

Re: EXOR or symmetric difference for the Counter class

2010-08-16 Thread Paddy
On 14 Aug, 18:14, Raymond Hettinger wrote: > On Aug 12, 1:20 pm, Paddy wrote: > > > I find myself needing to calculate the difference between two Counters > > or multisets or bags. > > > I want those items that are unique to each bag. > > Tell us about your use cases.  I'm curious how a program w

Re: Newbie: strftime object error message

2010-08-16 Thread Mark Lawrence
On 16/08/2010 17:47, fuglyducky wrote: I am trying to call a function with a couple additional parameters. Unfortunately, for whatever reason I am unable to get this to work. I am assuming that line is not passing correctly but I don't understand why??? I can't share all of the code because it h

Re: Newbie: strftime object error message

2010-08-16 Thread MRAB
fuglyducky wrote: I am trying to call a function with a couple additional parameters. Unfortunately, for whatever reason I am unable to get this to work. I am assuming that line is not passing correctly but I don't understand why??? [snip] The function's parameters are the wrong way round. -- h

Re: EOFError with fileinput

2010-08-16 Thread Alex van der Spek
Here is an excerpt. It works because the end condition is a fixed number (ln==10255), the approximate number of data lines in a file. If I replace that condition by EOFError, the program does not do the intended work. It appears as if EOFError is always true in this case. +

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

2010-08-16 Thread cbr...@cbrownsystems.com
On Aug 16, 1:23 am, Roald de Vries wrote: > On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote: > > > > > On Sun, Aug 15, 2010 at 4:36 PM, Baba wrote: > >> Hi Mel, > > >> indeed i thought of generalising the theorem as follows: > >> If it is possible to buy n, n+1,…, n+(x-1) sets of McNuggets, for   >

os.stat st_mtime problem

2010-08-16 Thread Alban Nona
Hello, Im stuck with this problem: I would like to os.stat st_mtime to copy only the files that have different modification date. so I found something on internet using this kind of line: if os.stat(dest).st_mtime - os.stat(src).st_mtime > 1: shutil.copy2 (src, dst) So I adapted it to my scri

Re: How to convert bytearray into integer?

2010-08-16 Thread Thomas Jollans
On Monday 16 August 2010, it occurred to Jacky to exclaim: > Hi there, > > Recently I'm facing a problem to convert 4 bytes on an bytearray into > an 32-bit integer. So far as I can see, there're 3 ways: > a) using struct module, Yes, that's what it's for, and that's what you should be using.

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

2010-08-16 Thread Ian Kelly
On Mon, Aug 16, 2010 at 12:43 PM, Roald de Vries wrote: >>> I'm pretty sure that if there's no common divisor for all three (or more) >>> packages (except one), there is a largest unpurchasable quantity. That >>> is: ∀ >>> i>1: ¬(i|a) ∨ ¬(i|b) ∨ ¬(i|c), where ¬(x|y) means "x is no divider of y" >>

Re: passing variables as object attributes

2010-08-16 Thread Terry Reedy
On 8/16/2010 9:40 AM, Vikas Mahajan wrote: Hello to all I am new to python. Hi, welcome to Python. Hint 1: 'Variable' is a rather loose term with many meanings. Better to think in terms of 'name' ('identifier'), which is specifically defined, and 'object'. I am facing problem to use varia

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

2010-08-16 Thread Baba
Hi Chas, Roald, These are all complicated formula that i believe are not expected at this level. If you look at the source (see my first submission) you will see that this exercise is only the second in a series called "Introduction to Programming". Therefore i am convinced that there is a much si

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Elizabeth D Rather
On 8/15/10 10:33 PM, Standish P wrote: ... I don't understand a lot of your post (and it's clear that I'm not alone). I don't know whether it's a (human) language problem or simply an issue of your having read too many books and not having enough practical experience, but at least I can try t

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
On Aug 16, 12:38 am, "Alf P. Steinbach /Usenet" wrote: > * Standish P, on 16.08.2010 09:20: > > > [garble garble] > > Nonsense article "We look for an exogenous stack" cross-posted to > >    [comp.lang.c], >    [comp.lang.c++], >    [comp.theory], >    [comp.lang.python], >    [comp.lang.forth]. >

Re: Newbie: strftime object error message

2010-08-16 Thread fuglyducky
On Aug 16, 10:27 am, Mark Lawrence wrote: > On 16/08/2010 17:47, fuglyducky wrote: > > > > > I am trying to call a function with a couple additional parameters. > > Unfortunately, for whatever reason I am unable to get this to work. I > > am assuming that line is not passing correctly but I don't

Re: os.stat st_mtime problem

2010-08-16 Thread MRAB
Alban Nona wrote: Hello, Im stuck with this problem: I would like to os.stat st_mtime to copy only the files that have different modification date. so I found something on internet using this kind of line: if os.stat(dest).st_mtime - os.stat(src).st_mtime > 1: shutil.copy2 (src, dst)

Re: Opposite of split

2010-08-16 Thread John Posner
On 8/16/2010 12:44 PM, Alex van der Spek wrote: Anybody catches any other ways to improve my program (attached), you are most welcome. 1. You don't need to separate out special characters (TABs, NEWLINEs, etc.) in a string. So: bt='-999.25'+'\t''-999.25'+'\t''-999.25'+'\t''-999.25'+'\t'+'

Re: Simple Problem but tough for me if i want it in linear time

2010-08-16 Thread Frederic Rentsch
On Sun, 2010-08-15 at 15:14 +0200, Peter Otten wrote: > ChrisChia wrote: > > > dataList = [a, b, c, ...] > > where a, b, c are objects of a Class X. > > In Class X, it contains self.name and self.number > > > > If i wish to test whether a number (let's say 100) appears in one of > > the object, a

Re: How to convert bytearray into integer?

2010-08-16 Thread Jacky
Hi Thomas, Thanks for your comments! Please check mine inline. On Aug 17, 1:50 am, Thomas Jollans wrote: > On Monday 16 August 2010, it occurred to Jacky to exclaim: > > > Hi there, > > > Recently I'm facing a problem to convert 4 bytes on an bytearray into > > an 32-bit integer.  So far as I c

Re: How to convert bytearray into integer?

2010-08-16 Thread Thomas Jollans
On Monday 16 August 2010, it occurred to Jacky to exclaim: > Hi Thomas, > > Thanks for your comments! Please check mine inline. > > On Aug 17, 1:50 am, Thomas Jollans wrote: > > On Monday 16 August 2010, it occurred to Jacky to exclaim: > > > Hi there, > > > > > > Recently I'm facing a problem

  1   2   >