Please help!!!
Hi to all! I want to do a calendar with pictures near months. I have designed the form's view.But unfortunately, I am not be able to save this view as an image file.And so I am not be able to print this image file too. Question: How can I determine the coordinates of a button?Namely How can I use the comand ImageGrab for this purpose? But only I wan to get the button's ares.Because my applicationis on this. Or if it's possible, how can I print the area of this button with the components on it? Thanks... -- http://mail.python.org/mailman/listinfo/python-list
Array? Please help.
I need a row of 127 bytes that I will use as a circular buffer. Into the bytes (at unspecified times) a mark (0http://mail.python.org/mailman/listinfo/python-list
Re: Please help!!!
On Apr 10, 2:43 pm, "gslm" <[EMAIL PROTECTED]> wrote: > Hi to all! > I want to do a calendar with pictures near months. > I have designed the form's view.But unfortunately, I am not be able to > save this view as an image file.And so I am not be able to print this > image file too. > Question: > How can I determine the coordinates of a button?Namely How can I use > the comand ImageGrab for this purpose? > > But only I wan to get the button's ares.Because my applicationis on > this. > > Or if it's possible, how can I print the area of this button with the > components on it? > > Thanks... Suggestion 1: "Please help!!!" is just about the worst newsgroup subject line there is (other than those related to government conspiracies or earthquake prediction). You are unlikely to attract the attention of those who really know anything - they are quite busy and must husband their time carefully. Instead, you'll get those who are idly curious, to see what sort of junk is floating about Usenet. Suggestion 2: Consider your audience. What the heck are you talking about?! Your post goes on about calendars and buttons and views. In fact, trying to make sense of your post, it sounds like you've done something truly bizarre, like making the whole view one giant button with lots of images on it, and you want to print it out when the "button" is clicked. Is this even a Python question? Any particular GUI package you are using, such as Tk, wxPython, QT, your own homebrew invention? ImageGrab? Sounds promising, what do the docs say? A more thorough discussion of these suggestions: http://www.catb.org/~esr/faqs/smart-questions.html -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help!!!
On 10 Nisan, 23:16, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > On Apr 10, 2:43 pm, "gslm" <[EMAIL PROTECTED]> wrote: > > > In fact ı know this, but I asked some questions like this, but ı haven't get > any answer.And I thought that may be it could be better to use a header like > this for help.Sorry! > > > Hi to all! > > I want to do a calendar with pictures near months. > > I have designed the form's view.But unfortunately, I am not be able to > > save this view as an image file.And so I am not be able to print this > > image file too. > > Question: > > How can I determine the coordinates of a button?Namely How can I use > > the comand ImageGrab for this purpose? > > > But only I wan to get the button's ares.Because my applicationis on > > this. > > > Or if it's possible, how can I print the area of this button with the > > components on it? > > > Thanks... > > Suggestion 1: "Please help!!!" is just about the worst newsgroup > subject line there is (other than those related to government > conspiracies or earthquake prediction). You are unlikely to attract > the attention of those who really know anything - they are quite busy > and must husband their time carefully. Instead, you'll get those who > are idly curious, to see what sort of junk is floating about Usenet. > > Suggestion 2: Consider your audience. What the heck are you talking > about?! Your post goes on about calendars and buttons and views. In > fact, trying to make sense of your post, it sounds like you've done > something truly bizarre, like making the whole view one giant button > with lots of images on it, and you want to print it out when the > "button" is clicked. Is this even a Python question? Any particular > GUI package you are using, such as Tk, wxPython, QT, your own homebrew > invention? ImageGrab? Sounds promising, what do the docs say? > > A more thorough discussion of these > suggestions:http://www.catb.org/~esr/faqs/smart-questions.html > > -- Paul- Alıntıyı gizle - > > - Alıntıyı göster - -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help!!!
On Apr 10, 3:59 pm, "gslm" <[EMAIL PROTECTED]> wrote: > On 10 Nisan, 23:16, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > > > > > On Apr 10, 2:43 pm, "gslm" <[EMAIL PROTECTED]> wrote: > > > In fact ý know this, but I asked some questions like this, but ý haven't > > get any answer.And I thought that may be it could be better to use a header > > like this for help.Sorry! > > > > Hi to all! > > > I want to do a calendar with pictures near months. > > > I have designed the form's view.But unfortunately, I am not be able to > > > save this view as an image file.And so I am not be able to print this > > > image file too. > > > Question: > > > How can I determine the coordinates of a button?Namely How can I use > > > the comand ImageGrab for this purpose? > > > > But only I wan to get the button's ares.Because my applicationis on > > > this. > > > > Or if it's possible, how can I print the area of this button with the > > > components on it? > > > > Thanks... > > > Suggestion 1: "Please help!!!" is just about the worst newsgroup > > subject line there is (other than those related to government > > conspiracies or earthquake prediction). You are unlikely to attract > > the attention of those who really know anything - they are quite busy > > and must husband their time carefully. Instead, you'll get those who > > are idly curious, to see what sort of junk is floating about Usenet. > > > Suggestion 2: Consider your audience. What the heck are you talking > > about?! Your post goes on about calendars and buttons and views. In > > fact, trying to make sense of your post, it sounds like you've done > > something truly bizarre, like making the whole view one giant button > > with lots of images on it, and you want to print it out when the > > "button" is clicked. Is this even a Python question? Any particular > > GUI package you are using, such as Tk, wxPython, QT, your own homebrew > > invention? ImageGrab? Sounds promising, what do the docs say? > > > A more thorough discussion of these > > suggestions:http://www.catb.org/~esr/faqs/smart-questions.html > > > -- Paul- Alýntýyý gizle - > > > - Alýntýyý göster -- Hide quoted text - > > - Show quoted text - Just go do some homework for yourself. Then if you still need help, imagine the person you want to help you reading the subject and your question - how will they know what you need help with? how will they recognize what software you are using, what version of the software, what things you have tried and didn't work, and how did they fail? If you got a traceback, include it, plus the *actual code* that caused it. Then come back with a posting (and posting subject) that that person can understand and respond to. But don't post with "Please help!!!" - that's like posting on a job board with the subject "Need a job". -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help!!!
gslm wrote: > On 10 Nisan, 23:16, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > >>On Apr 10, 2:43 pm, "gslm" <[EMAIL PROTECTED]> wrote: >> >> >>In fact ı know this, but I asked some questions like this, but ı haven't get >>any answer.And I thought that may be it could be better to use a header like >>this for help.Sorry! >> >> >>>Hi to all! >>>I want to do a calendar with pictures near months. >>>I have designed the form's view.But unfortunately, I am not be able to >>>save this view as an image file.And so I am not be able to print this >>>image file too. >>>Question: >>>How can I determine the coordinates of a button?Namely How can I use >>>the comand ImageGrab for this purpose? >> >>>But only I wan to get the button's ares.Because my applicationis on >>>this. >> >>>Or if it's possible, how can I print the area of this button with the >>>components on it? >> >>>Thanks... >> >>Suggestion 1: "Please help!!!" is just about the worst newsgroup >>subject line there is (other than those related to government >>conspiracies or earthquake prediction). You are unlikely to attract >>the attention of those who really know anything - they are quite busy >>and must husband their time carefully. Instead, you'll get those who >>are idly curious, to see what sort of junk is floating about Usenet. >> >>Suggestion 2: Consider your audience. What the heck are you talking >>about?! Your post goes on about calendars and buttons and views. In >>fact, trying to make sense of your post, it sounds like you've done >>something truly bizarre, like making the whole view one giant button >>with lots of images on it, and you want to print it out when the >>"button" is clicked. Is this even a Python question? Any particular >>GUI package you are using, such as Tk, wxPython, QT, your own homebrew >>invention? ImageGrab? Sounds promising, what do the docs say? >> >>A more thorough discussion of these >>suggestions:http://www.catb.org/~esr/faqs/smart-questions.html >> >>-- Paul- Alıntıyı gizle - >> >>- Alıntıyı göster - > > > gslm: Just so you know, you are annoying everyone on this list with your ill formed "questions"--Not just Paul who happened to be nice enough to give you some advice. James -- http://mail.python.org/mailman/listinfo/python-list
ArchGenXML please help
I am creating a workflow in plone using argouml and archgenxml. I have been following the steps on the site:- http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml However I am confused at step 9 in creating the class section, where it says: "Now, save this file as "ProcessImprovement.zargo". Pull up a command prompt and navigate to that directory. Make sure that you've added the ArchGenXML directory to your env path, and type the following: C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo" I have saved the file in the location C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo However I dont know what to type in the python command prompt!!! Can anyone help my, I would be very greatful, or if I am in the wrong place do you know another forum where I could go as I have tried the plone online on and it is no good. Thank you. -- View this message in context: http://www.nabble.com/ArchGenXML-please-help-tf2966867.html#a8301441 Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Performance Issues please help
I was testing this piece of code and it takes about 24-30 seconds to do a look up on a list(m) of size 1000x1000 m -> list of size 1000x1000 import time print time.ctime() box = {} for r,row in enumerate(m): for c,e in enumerate(row): if box.has_key(e): params = box[e] box[e] = ( min(c, params[0]), min(r, params[1]), max(c, params[2]), max(r, params[3] ) ) else: box[e] = [c, r, c, r] print time.ctime() Can some one tell me what exactly is taking more time here. Is it because I am using dictionaries or what is the problem. Can some one help me improve this .Is there a better way to write this. -- http://mail.python.org/mailman/listinfo/python-list
Please Help with replaceChild
How can I do the following in python: compare the text in the element tags with the elements tags in filling and if they match replace the text within the elements tags with the text in the matching element tag of fillin. For example Since the text Monday in form matches the Element tag in fillin put maandag in the element tag of Monday. Kind of a Pseudo Code Fo information: get element tags for li get text for li Fi information: get childtags for dutchdays if(text for li=child tags for dutchdays): replace child tags for dutchdays text with text for li Some pieces of code that I tried out but cannot put together to get the results. import xml.dom.minidom from xml.dom.minidom import parseString import xml.xpath form=""" My Sample Web Page What are the weekdays? Monday """ fillin=""" maandag dinsdag woensdag donderdag vrijdag zaterdag zondag """ Fo = xml.dom.minidom.parseString(form) Fi = xml.dom.minidom.parseString(fillin) form_doc = parseString(form) fill_doc = parseString(fillin) for li in xml.xpath.Evaluate("//li", form_doc): li.normalize() day_text = li.childNodes[0] day_str = day_text.nodeValue for Monday in xml.xpath.Evaluate("//Monday", fill_doc): Monday.normalize() mon_text = Monday.childNodes[0] mon_str = mon_text.nodeValue #I want the to put the replace here put I have tried everything and errors keep coming up I am totally lost and do not know what to do could someone explain to me what to do because I have looked at the python.org material and have accomplished nothing. Thanks -- http://mail.python.org/mailman/listinfo/python-list
please help the newbie!
In my Python research, I have found a nice little voice recognition script on the internet that does exactly what I need, and the demo recognizes phrases with pretty much 100%accuracy. The script can be found here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/93025 What I want to do is make this code into a module, so I can use it in other programs. For example: import voicerecognition as vr vr.StartRecognition(["one", "two", "three"]) result = vr.GetRecognized() if result == "one": print "You said: one" else: print "You did not say 'one'." Any help would be appreciated. I have tried this, but IDLE keeps freezing whenever I try to use the module with a test script. As I said, I am a newbie and do not know very much about classes, instances, and all those __funky__ modules. Can anybody give me some tips on turning this into a module??? Thank you! -- http://mail.python.org/mailman/listinfo/python-list
graph display(please help)
I heard from my friend who used to program in JAVA, it is really easy to do graph display in JAVA. I wonder whether there are similiar packages in Python I can use. Since I know a little bit Python syntax already, I can easily learn more in Python. I want to display connected graph(directed or undirected, most often trees) with coloring on them. Thanks for any suggestions!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Dr. Pastor schrieb: > I need a row of 127 bytes that I will use as a > circular buffer. Into the bytes (at unspecified times) > a mark (0 After some time the "buffer" will contain the last 127 marks. > (A pointer will point to the next byte to write to.) > What would be the Pythonic way to do the above? > Thanks for any guidance. Use a list, use append and slicing on it: max_size = 10 buffer = [] for i in xrange(100): buffer.append(i) buffer[:] = buffer[-max_size:] print buffer Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Diez B. Roggisch wrote: > Dr. Pastor schrieb: > > I need a row of 127 bytes that I will use as a > > circular buffer. Into the bytes (at unspecified times) > > a mark (0 > After some time the "buffer" will contain the last 127 marks. > > (A pointer will point to the next byte to write to.) > > What would be the Pythonic way to do the above? > > Thanks for any guidance. > > Use a list, use append and slicing on it: > > > max_size = 10 > buffer = [] > > for i in xrange(100): > buffer.append(i) > buffer[:] = buffer[-max_size:] > print buffer > > > Diez You're not serious about this, are you ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Dr. Pastor wrote: > I need a row of 127 bytes that I will use as a > circular buffer. Into the bytes (at unspecified times) > a mark (0 After some time the "buffer" will contain the last 127 marks. Sounds a lot like homework. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
No it is not home work. (I have not did any home work for more than 50 years.) I am a beginner, and just do not see a really proper way to program the question. Thanks anyhow. Scott David Daniels wrote: > Dr. Pastor wrote: > >> I need a row of 127 bytes that I will use as a >> circular buffer. Into the bytes (at unspecified times) >> a mark (0> After some time the "buffer" will contain the last 127 marks. > > > Sounds a lot like homework. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Dr. Pastor wrote: > Scott David Daniels wrote: >> Dr. Pastor wrote: >>> I need a row of 127 bytes that I will use as a >>> circular buffer. Into the bytes (at unspecified times) >>> a mark (0>> After some time the "buffer" will contain the last 127 marks. >> Sounds a lot like homework. > No it is not home work. OK, taking you at your word, here's one way: class Circular(object): def __init__(self): self.data = array.array('b', [0] * 127) self.point = len(self.data) - 1 def mark(self, value): self.point += 1 if self.point >= len(self.data): self.point = 0 self.data[self.point] = value def recent(self): result = self.data[self.point :] + self.data[: self.point] for n, v in enumerate(result): if v: return result[n :] return result[: 0] # an empty array -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Scott David Daniels wrote: > Dr. Pastor wrote: >> Scott David Daniels wrote: >>> Dr. Pastor wrote: I need a row of 127 bytes that I will use as a circular buffer. Into the bytes (at unspecified times) a mark (0>>> After some time the "buffer" will contain the last 127 marks. >>> Sounds a lot like homework. >> No it is not home work. > > OK, taking you at your word, here's one way: > (and some untested code) As penance for posting untested code, here is a real implementation: import array class Circular(object): '''A circular buffer, holds only non-zero entries''' def __init__(self, size=127): '''Create as N-long circular buffer .data is the circular data store. .point is the index of the next value to write ''' self.data = array.array('b', [0] * size) self.point = 0 def mark(self, value): '''Add a single value (non-zero) to the buffer''' assert value self.data[self.point] = value self.point += 1 if self.point >= len(self.data): self.point = 0 def recent(self): '''Return the most recent values saved.''' result = self.data[self.point :] + self.data[: self.point] for n, v in enumerate(result): if v: return result[n :] return result[: 0] # an empty array Tests: c = Circular(3) assert list(c.recent()) == [] c.mark(12) assert list(c.recent()) == [12] c.mark(11) assert list(c.recent()) == [12, 11] c.mark(10) assert list(c.recent()) == [12, 11, 10] c.mark(9) assert list(c.recent()) == [11, 10, 9] --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Many thanks to you all. (Extra thanks to Mr. Daniels.) Dr. Pastor wrote: > I need a row of 127 bytes that I will use as a > circular buffer. Into the bytes (at unspecified times) > a mark (0 After some time the "buffer" will contain the last 127 marks. > (A pointer will point to the next byte to write to.) > What would be the Pythonic way to do the above? > Thanks for any guidance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
George Sakkis schrieb: > Diez B. Roggisch wrote: >> Dr. Pastor schrieb: >>> I need a row of 127 bytes that I will use as a >>> circular buffer. Into the bytes (at unspecified times) >>> a mark (0>> After some time the "buffer" will contain the last 127 marks. >>> (A pointer will point to the next byte to write to.) >>> What would be the Pythonic way to do the above? >>> Thanks for any guidance. >> Use a list, use append and slicing on it: >> >> >> max_size = 10 >> buffer = [] >> >> for i in xrange(100): >> buffer.append(i) >> buffer[:] = buffer[-max_size:] >> print buffer >> >> >> Diez > > You're not serious about this, are you ? Tell me why I shouldn't. I presumed he's after a ringbuffer. Ok, the above lacks a way to determine the amount of bytes added since the last read. Add a counter if you want. And proper synchronization in case of a multithreaded environment. But as the OP was sketchy about what he actually needs, I thought that would at least give him a start. Maybe I grossly misunderstood his request. But I didn't see your better implementation so far. So - enlighten me. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Array? Please help.
Diez B. Roggisch wrote: > George Sakkis schrieb: > > Diez B. Roggisch wrote: > >> Dr. Pastor schrieb: > >>> I need a row of 127 bytes that I will use as a > >>> circular buffer. Into the bytes (at unspecified times) > >>> a mark (0 >>> After some time the "buffer" will contain the last 127 marks. > >>> (A pointer will point to the next byte to write to.) > >>> What would be the Pythonic way to do the above? > >>> Thanks for any guidance. > >> Use a list, use append and slicing on it: > >> > >> > >> max_size = 10 > >> buffer = [] > >> > >> for i in xrange(100): > >> buffer.append(i) > >> buffer[:] = buffer[-max_size:] > >> print buffer > >> > >> > >> Diez > > > > You're not serious about this, are you ? > > Tell me why I shouldn't. I presumed he's after a ringbuffer. Ok, the > above lacks a way to determine the amount of bytes added since the last > read. Add a counter if you want. And proper synchronization in case of a > multithreaded environment. But as the OP was sketchy about what he > actually needs, I thought that would at least give him a start. > > Maybe I grossly misunderstood his request. But I didn't see your better > implementation so far. So - enlighten me. Strange; there are two threads on this and my reply was sent to the first one: http://tinyurl.com/lm2ho. In short, adding a new mark should be a simple O(1) operation, not an O(buf_size). This is textbook material, that's why I wasn't sure if you meant it. George -- http://mail.python.org/mailman/listinfo/python-list
Re: ArchGenXML please help
tonydevlin a écrit : > I am creating a workflow in plone using argouml and archgenxml. I have been > following the steps on the site:- > http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml > > However I am confused at step 9 in creating the class section, where it > says: > "Now, save this file as "ProcessImprovement.zargo". Pull up a command > prompt and navigate to that directory. Make sure that you've added the > ArchGenXML directory to your env path, and type the following: > C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo" > > I have saved the file in the location > C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo > However I dont know what to type in the python command prompt!!! Which *python* command prompt ? The author is talking about a shell, here (you know, this strange stuff that looks like good ole time DOS...). -- http://mail.python.org/mailman/listinfo/python-list
Re: ArchGenXML please help
Bruno Desthuilliers wrote: > > tonydevlin a écrit : >> I am creating a workflow in plone using argouml and archgenxml. I have >> been >> following the steps on the site:- >> http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml >> >> However I am confused at step 9 in creating the class section, where it >> says: >> "Now, save this file as "ProcessImprovement.zargo". Pull up a command >> prompt and navigate to that directory. Make sure that you've added the >> ArchGenXML directory to your env path, and type the following: >> C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo" >> >> I have saved the file in the location >> C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo >> However I dont know what to type in the python command prompt!!! > > Which *python* command prompt ? The author is talking about a shell, > here (you know, this strange stuff that looks like good ole time DOS...). > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > I yes sorry I was obviously not thinking properly, however there is still > a problem, when I run this in dos after I have changed to the correct > directory the ArchGenXML file that I downloaded does not work. I renamed > it from its original name because that did not work, it just came up with > can not find program for it to run off. It still does the same. > > -- View this message in context: http://www.nabble.com/ArchGenXML-please-help-tf2966867.html#a8302734 Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: ArchGenXML please help
tonydevlin a écrit : > > > Bruno Desthuilliers wrote: > >>tonydevlin a écrit : >> >>>I am creating a workflow in plone using argouml and archgenxml. I have >>>been >>>following the steps on the site:- >>>http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml >>> >>>However I am confused at step 9 in creating the class section, where it >>>says: >>>"Now, save this file as "ProcessImprovement.zargo". Pull up a command >>>prompt and navigate to that directory. Make sure that you've added the >>>ArchGenXML directory to your env path, and type the following: >>>C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo" >>> >>>I have saved the file in the location >>>C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo >>>However I dont know what to type in the python command prompt!!! >> >>Which *python* command prompt ? The author is talking about a shell, >>here (you know, this strange stuff that looks like good ole time DOS...). >> >> >>-- >>http://mail.python.org/mailman/listinfo/python-list >> >> >>I yes sorry I was obviously not thinking properly, however there is still >>a problem, when I run this in dos after I have changed to the correct >>directory the ArchGenXML file that I downloaded does not work. "does not work" is the worst possible description of a problem. >> I renamed >>it from its original name because that did not work, it just came up with >>can not find program for it to run off. It still does the same. The same what ? (no, don't answer) Tony, I don't mean to be rude, but may I suggest that you first learn to use your system, then learn to run a Python program from the command line on your system ? FWIW, none of the problems you exposed so far is related to Python... -- http://mail.python.org/mailman/listinfo/python-list
please help a newbie
Hi all I have a binary file of about 600kbytes - I want to break it up in file chunks of 1085 bytes - every file must have a new file name. The data is binary video frames (370 frames) - I want to play the data back into an embedded system frame/file by file. I am a complete Python newby - but have C/C++ skills. Please supply/help me with an snippet or example Thanks Pieter -- http://mail.python.org/mailman/listinfo/python-list
Please help here: python <==> COM
Hi,all I'm scripting flashget (A download management tool, http://www.amazesoft.com/) using python win32 extension, opening a downloading dialog. The following pythong code NOT work: CODE BEGIN #!/usr/bin/env python # -*- coding: cp936 -*- import win32com.client flashget = win32com.client.Dispatch('JetCar.Netscape') params = ('http://test.com/1', 'http://test.com/2', 'http://test.com/3', 'http://test.com/4', 'http://test.com/5') flashget.AddUrlList(params) CODE END It complaints the following: File "", line 2, in AddUrlList pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146828283), None) But the following VBS code does the tricky: CODE BEGIN Dim params(4) set flashget=CreateObject("JetCar.Netscape") params(0) = "http://test.com/1"; params(1) = "http://test.com/2"; params(2) = "http://test.com/3"; params(3) = "http://test.com/4"; params(4) = "http://test.com/5"; flashget.AddUrlList params CODE END Any hints? -- Best Regards, Wang Kebo http://www.huihoo.org/~mep -- http://mail.python.org/mailman/listinfo/python-list
please help on installation process
Hi I had downloaded python-2.4.msi and I have Windows Installer V2.00.2600.2 on my machine (my OS is Win 2K Professional). But every time I try to run python-2.4.msi I am getting the error message: "This installation package could not be opened..." I am a newsier in python, I would be grateful if you please advise me what to do. Regards Arindam Mitra WinCliff Technologies [EMAIL PROTECTED] Phone : +919831190761 (www.wincliff.com) -- http://mail.python.org/mailman/listinfo/python-list
Please help for Python programming
I don't know why i entered the below code and it will miss some records. Anyone can help me??? users = {} users1 = {} while 1: user, serviceType, msgType, inOut, date, time, numBytes = aLog.GetNextMessage("") fullmsg = serviceType + "|" + msgType + "|" + inOut bytemsg = user + " " + serviceType + " " + msgType + " " + inOut + " " + numBytes user1 = user msgDict = {} byteDict = {} print bytemsg # 53 records in source file msgDict = users[user] # get the cum statistics for this user byteDict = users1[user1] print bytemsg # 50 records in source file -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
PyPK wrote: > I was testing this piece of code and it takes about 24-30 seconds to do > a look up on a list(m) of size 1000x1000 > m -> list of size 1000x1000 > import time > print time.ctime() > box = {} > for r,row in enumerate(m): > for c,e in enumerate(row): > if box.has_key(e): >params = box[e] >box[e] = ( min(c, params[0]), min(r, params[1]), > max(c, params[2]), max(r, params[3] ) ) > else: > box[e] = [c, r, c, r] > print time.ctime() > > Can some one tell me what exactly is taking more time here. Is it > because I am using dictionaries or what is the problem. Can some one > help me improve this .Is there a better way to write this. > Without gross changes to the algorithm, and in no particular order: 0. Stop worrying. Find something else to do during the 30 seconds. 1. Use psyco, if your [unspecified] platform supports it. 2. Why has_key()? Try "if e in box:" instead, if your [unspecified] version of Python supports it. If it doesn't, (a) consider upgrading (b) try doing box_has_key = box.has_key outside the loops and using the result inside the loops. 3. Ensure this code is inside a function, not at global level in a script [not apparent from your post]. 4. Outside the loops, put "local_min = min", ditto for max. Then use box[e] = (local_min(c, etc etc 5. Upgrade your [unspecified] hardware. 6. Use try/except, if indicated by the [unspecified] percentage of times "e in box" is true. Hint: printing len(box) at the end might be useful. 7. Consider using pyrex. 8. Consider using numarray/mumeric. Info req'd for discussing algorithm changes: 1. How much free memory do you have? 2. What can you tell us about the distribution of "e"? 3. Is "m" a rectangle, or are the rows of variable length? 4. Do you have control over "m" i.e. are you stuck with that data structure, or can we design a different one? -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
>Info req'd for discussing algorithm changes: >1. How much free memory do you have? - Memory is not a problem but I am working on some timing constraints.Thats is the reason I am a bit concerned abt these 30 seconds > 2. What can you tell us about the distribution of "e"? - the distribution of e is not fixed.It changes based on what comes first in the scan of the list. > 3. Is "m" a rectangle, or are the rows of variable length? - m is not a restnagle .its of varied dimensions. > 4. Do you have control over "m" i.e. are you stuck with that data structure, or can we design a different one? -I can use 'm' as an array or a list. Other than that I am stuck. I am suspecious abput dictionary approach here. Is this slower than if i do it with arrays or lists with index of array as my key ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
PyPK wrote: > > I am suspecious abput dictionary approach here. Is this slower than if > i do it with arrays or lists with index of array as my key ? > "with index of array as my key" is either redundant -- indicating that your answer to my question about "e" should have included something like "e is an integer that can range from blah0 to blah_max" -- or not understandable. In any case, seeing that the code in question is only a few lines, why don't *you* write an alternative version and see how fast it runs? And let us know? -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
PyPK wrote: > I was testing this piece of code and it takes about 24-30 seconds to do > a look up on a list(m) of size 1000x1000 > m -> list of size 1000x1000 > import time > print time.ctime() > box = {} > for r,row in enumerate(m): > for c,e in enumerate(row): > if box.has_key(e): >params = box[e] >box[e] = ( min(c, params[0]), min(r, params[1]), > max(c, params[2]), max(r, params[3] ) ) > else: > box[e] = [c, r, c, r] > print time.ctime() > > Can some one tell me what exactly is taking more time here. Is it > because I am using dictionaries or what is the problem. Can some one > help me improve this .Is there a better way to write this. AFAICT the row index 'r' can only grow. Therefore one min() and one max() should be superfluous (untested): def make_box(m): box = {} for r, row in enumerate(m): for c, e in enumerate(row): if e in box: left, top, right, bottom = box[e] box[e] = (min(c, left), top, max(c, right), r) else: box[e] = (c, r, c, r) return box Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
Yep that improved the speed by about 50% now it takes about 10 secs instead of 24 seconds..Thanks much. I guess that is the best we could do right.It would be really helpful if I could get it less than 5 seconds. Any suggestions on that?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
PyPK wrote: > Yep that improved the speed by about 50% now it takes about 10 secs > instead of 24 seconds..Thanks much. I guess that is the best we could > do right.It would be really helpful if I could get it less than 5 > seconds. Any suggestions on that?? > Things to try: * in-lining the min and max expressions * depending on the distribution of e, it may be faster to catch KeyErrors def search1(m): box = {} for r,row in enumerate(m): for c,e in enumerate(row): try: minc, minr, maxc, maxr = box[e] box[e] = ( c < minc and c or minc, r < minr and r or minr, c > maxc and c or maxc, r > maxr and r or maxr) except KeyError: box[e] = (c, r, c, r) return box Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
Michael Spencer wrote: > def search1(m): > box = {} > for r,row in enumerate(m): > for c,e in enumerate(row): > try: > minc, minr, maxc, maxr = box[e] > box[e] = ( c < minc and c or minc, > r < minr and r or minr, > c > maxc and c or maxc, > r > maxr and r or maxr) > except KeyError: > box[e] = (c, r, c, r) > return box > > Michael > Sorry, my earlier solution was incorrect since: c < minc and c or minc # evaluates to minc if c == 0 Two of the tests are unnecessary, as pointed out by Peter The remaining test: c > maxc and c or maxc does not suffer from the same problem, since c cannot both be 0 and greater than maxc The following version, still untested ;-) has the correction: def search2(m): box = {} for r,row in enumerate(m): for c,e in enumerate(row): try: # use this form if e will be found 90%+ of the time # otherwise, use: if e in box: minc, minr, maxc, maxr = box[e] # note correction for c == 0 # also Peter's simplification box[e] = ( c and (c < minc and c or minc), minr, c > maxc and c or maxc, r) except KeyError: box[e] = (c, r, c, r) return box Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance Issues please help
Michael Spencer wrote: > minc, minr, maxc, maxr = box[e] > # note correction for c == 0 > # also Peter's simplification > box[e] = ( c and (c < minc and c or minc), >minr, >c > maxc and c or maxc, >r) > This may be slightly faster (when c > 0), and slightly less opaque: minc, minr, maxc, maxr = box[e] # note correction for c == 0 # also Peter's simplification if c < minc: minc = c box[e] = ( minc, minr, c > maxc and c or maxc, r) -- http://mail.python.org/mailman/listinfo/python-list
Importing a class, please help...
Hi, Newbie to Python and I have a question please. I am using Windows XP, SPE 0.8.2.a and Python24. I have done this: import sys print sys.path no problem there, sys imports just fine. I have a folder that I called c\JavaProjects\PythonTesting and it shows up in the output from sys.path above. I have dropped a very simple Jar in that folder and I have attempted to do an Import on it. This is where things fail. I cannot see the contents of my Jar. What am I missing here? Would somebody please drop me a hint, please? I would HIGHLY appreciate an example; does anybody know of a website or page that would show me how to do this? I realize this is a simple question and I appreciate any help somebody would give me. Regards, joe -- http://mail.python.org/mailman/listinfo/python-list
Re: graph display(please help)
questions? wrote: > I heard from my friend who used to program in JAVA, it is really easy > to do graph display in JAVA. > > I wonder whether there are similiar packages in Python I can use. Since > I know a little bit Python syntax already, I can easily learn more in > Python. > > I want to display connected graph(directed or undirected, most often > trees) with coloring on them. > The just released yapgvb would seem to fit: http://sourceforge.net/projects/yapgvb > Thanks for any suggestions!!! > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: graph display(please help)
questions? wrote: > I heard from my friend who used to program in JAVA, it is really easy > to do graph display in JAVA. > Thanks for any suggestions!!! Jython -- Mladen Adamovic home page: http://home.blic.net/adamm -- http://mail.python.org/mailman/listinfo/python-list
Pycron for windows - please help
Hey all, I'm using Pycron for windows to run 5 scripts at various times of the day, all of which work well. I recently added a 6th job, a simply file copy operation, and it won't run. Once the job is configured, I click the test execution button, and it works fine. However, it won't run automatically. I looked in the pycron.log file, and I noticed that for the entires of my new job, I see "rc=4" and the end of each line. All other jobs have "rc=0" at the end of the line. I assume then, that rc=4 is a reference to an error code of some kind, but there is no information on this in the readme.txt, at the pycron website, or here in groups. Does anyone know how to troubleshhot this? Thanks in advance. Al -- http://mail.python.org/mailman/listinfo/python-list
TK-grid problem, please help
hi, I have a question about how to use .grid_forget (in python/TK) I need to work on grid repeatly. everytime when a button is pressed, the rows of grid is different. such like, first time, it generate 10 rows of data. 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data every time. how can I do it? by grid_forger()?, then would anyone can help on how to use grid_forget() the sample code as following: #begin of program### from Tkinter import * def mygrid(text): how to use grid_forget() to clean the grid??### rows = [] count=int(text) for i in range(count): cols = [] for j in range(4): e = Entry(frame3, relief=RIDGE) e.grid(row=i, column=j, sticky=NSEW) e.insert(END, '%d.%d' % (i, j)) cols.append(e) rows.append(cols) root=Tk() frame1=Frame(root, width=150, height=100) frame1.pack() text=Entry(frame1) text.pack(side=LEFT) button=Button(frame1, text='generate grid', command=(lambda: mygrid(text.get( button.pack() frame2=Frame(root, width=150, height=100) frame2.pack() button2=Button(frame2, text='exit', command=root.quit) button2.pack() frame3=Frame(root, width=150, height=300) frame3.pack() root.mainloop() #end of program### -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help here: python <==> COM
Resolved. Thanks anyway -- Best Regards, Wang Kebo http://www.huihoo.org/~mep "mep" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi,all > I'm scripting flashget (A download management tool, > http://www.amazesoft.com/) using > python win32 extension, opening a downloading dialog. > The following pythong code NOT work: > CODE BEGIN > #!/usr/bin/env python > # -*- coding: cp936 -*- > > import win32com.client > > flashget = win32com.client.Dispatch('JetCar.Netscape') > params = ('http://test.com/1', >'http://test.com/2', >'http://test.com/3', >'http://test.com/4', >'http://test.com/5') > > flashget.AddUrlList(params) > CODE END > > It complaints the following: > File "", line 2, in AddUrlList > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, > None, 0, -2146828283), None) > > But the following VBS code does the tricky: > CODE BEGIN > Dim params(4) > set flashget=CreateObject("JetCar.Netscape") > > params(0) = "http://test.com/1"; > params(1) = "http://test.com/2"; > params(2) = "http://test.com/3"; > params(3) = "http://test.com/4"; > params(4) = "http://test.com/5"; > > flashget.AddUrlList params > CODE END > > Any hints? > > -- > Best Regards, > Wang Kebo > > http://www.huihoo.org/~mep > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help here: python <==> COM
heheh... this was funny in your posting. :) >The following *pythong* ( so this is what a Python wearing a thong is called .. > hmmm...) code NOT work.. On Sun, 5 Dec 2004 16:18:33 +0800, mep <[EMAIL PROTECTED]> wrote: > Resolved. Thanks anyway [snip] -- cheers, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-list
Please help -- Pmw PanedWidget inside ScrolledFrame
I'm trying to use a Pmw.ScrolledFrame which contains a PanedWidget. But I can't get the PanedWidget to expand to fill the interior frame. It expands fine if I just grid it into the toplevel window; and when I tried gridding DIFFERENT widgets into the ScrolledFrame, they expanded just fine. So both the ScrolledFrame and PanedWidget seem to work OK on their own, but when I try to put one inside the other, something goes haywire. Can anyone help please? -- http://mail.python.org/mailman/listinfo/python-list
Re: please help on installation process
On Fri, 18 Mar 2005 15:05:07 +0530, Arindam <[EMAIL PROTECTED]> wrote: > I had downloaded python-2.4.msi and I have Windows Installer V2.00.2600.2 on > my machine (my OS is Win 2K Professional). But every time I try to run > python-2.4.msi I am getting the error message: "This installation package > could not be opened..." I am a newsier in python, I would be grateful if you > please advise me what to do. Chances are it's an incomplete download. My python-2.4.msi is 10.3 MB (10,887,168 bytes) - how big is yours? If it's smaller, try downloading it again. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
[EMAIL PROTECTED] wrote: > I don't know why i entered the below code and it will miss some > records. > Anyone can help me??? Sorry, my mindreading brain extension is at the service right now, so I can't guess what that piece of syntactically incorrect code is supposed to do and what error message it produces. Until you come up with a more detailed error description, I'll have a good read at http://www.catb.org/~esr/faqs/smart-questions.html Which I suggest you read too. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
[EMAIL PROTECTED] wrote: I don't know why i entered the below code And we don't know either !-) and it will miss some records. Anyone can help me??? If you hope to get some useful help, it would be a good idea to follow Diez's advice (see other post in this thread) users = {} users1 = {} while 1: Unless there is a break somewhere in the following code (I can't find one...), this is an endless loop. But you know this, don't you ? user, serviceType, msgType, inOut, date, time, numBytes = aLog.GetNextMessage("") fullmsg = serviceType + "|" + msgType + "|" + inOut tip : use string formating instead (string concatenations are to be avoided in Python), ie: fullmsg = "%s | %s | %s" % (serviceType, msgType, inOut) bytemsg = user + " " + serviceType + " " + msgType + " " + inOut + " " + numBytes idem user1 = user msgDict = {} byteDict = {} This re-initialises both dicts on each iteration. Is this really what you want ? print bytemsg # 53 records in source file Here you have an obvious indentation problem. This code *cannot* run. Take care of not mixing tabs and spaces (tip: configure you editor to only use spaces) msgDict = users[user] # get the cum statistics for this user Given the above binding of 'users' as an empty dict, this should raise a KeyError. It's also overwriting the previous binding of msgDict. byteDict = users1[user1] idem. Also, you don't need to bind 2 different names to the same value to use this value as key in 2 different dicts. Here you could as well use user for both dicts, since user and user1 are bound to the same value. print bytemsg # 50 records in source file In addition to Diez's reading advice, here are some that are more specific to code-related questions: 1/ paste code, dont re-type it ... this avoid stupid typos 2/ post running code ... if the code is so obviously broked that it cannot even compile|run, readers will have to fix it first - which they'll probably won't do. Even if they do, they may not fix it the right way. Everyone's losing its time... 3/ post the smallest possible bit of code that exhibit your problem ... no one's going to [read 3000 lines of code | install 30 gigabytes of third part libs | etc...] just to help you. Moreover, quite often, one finds the bug while reducing the problematic code to it's smallest possible. And one last: don't forget to put your bullet-proof jacket on before reading the answers !-) (well, c.l.py is probably one of the friendliest groups on usenet, but still, this is usenet). -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
This is what I see (minus the '> '): > while 1: > user, serviceType, msgType, inOut, date, time, numBytes = > aLog.GetNextMessage("") [etc] Advice: use spaces, not tabs, to indent posted code (some readers discard tabs). Don't use google groups to post code (it deletes initial spaces and won't, apparently, fix this bug). Use news.gmane.org group gmane.comp.python.genral instead (I believe they also have web interface in addition to newsreader interface). If you really, really must post thru google, prefix lines with char such as '|', even tho this kill cut and pastability. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
Actually, this script will open a text file which is seperated by tabs. The PRINT code is for my testing. My problem is bytemsg will be omitted some records. For example, my text file have 53 records about username. After byteDict = users1[user1], it remains 50 records in the output file. I would like to know how to culmulate some data by users. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
[EMAIL PROTECTED] wrote: (snip) The PRINT code is for my testing. My problem is bytemsg will be omitted some records. For example, my text file have 53 records about username. After byteDict = users1[user1], Which, from your previous snippet, should raise a KeyError... If it does, then first understand why and fix it. If it does not, then the code you posted is absolutely useless for us to help you. it remains 50 records in the output file. There is nothing about reading and parsing file in the code you posted. I'm afraid you did not follow Diez's advice, nor mine. Please re-read my previous post, take appropriate action, and re-post with the minimum *working* snippet that exhibit your problem. I would like to know how to culmulate some data by users. data.txt user1;aaa;000 user2;aab;001 user3;aac;002 user1;aad;004 user3;aae;005 user1;aaf;006 user2;aag;007 user2;aah;008 user2;aak;009 user1;zzz;999 accu.py import sys import pprint try: f = open('data.txt', 'r') except IOError, e: print >> sys.stderr, "Cannot open file data.txt for reading : %s" % e sys.exit(1) users = {} for line in f: try: user, data1, data2 = line.strip().split(';') except ValueError: print >> sys.stderr, "wrong file format" f.close() sys.exit(1) try: users[user].append("%s : %s" % (data1, data2)) except KeyError: users[user] = ["%s : %s" % (data1, data2)] f.close() print "collected data:"; pprint.pprint(users) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
Terry, This was posted from google groups, can you see the indents? # code snippet convertpage = 0 form = None for o, a in opts: if o in ["-h", "--help"]: Usage() sys.exit() if o in ["-o", "--output", "--out"]: output = a if o in ["-i", "--input", "--in"]: input = a if input in [".", "cwd"]: input = os.getcwd() Notice the 'fixed font / proportional font' link in the top right corner. I think they have "fixed" the problem. M.E.Farmer Terry Reedy wrote: > This is what I see (minus the '> '): > > > while 1: > > user, serviceType, msgType, inOut, date, time, numBytes = > > aLog.GetNextMessage("") > [etc] > > Advice: use spaces, not tabs, to indent posted code (some readers discard > tabs). Don't use google groups to post code (it deletes initial spaces and > won't, apparently, fix this bug). Use news.gmane.org group > gmane.comp.python.genral instead (I believe they also have web interface in > addition to newsreader interface). If you really, really must post thru > google, prefix lines with char such as '|', even tho this kill cut and > pastability. > > Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Terry, > This was posted from google groups, can you see the indents? Yes, looks good > # code snippet >convertpage = 0 >form = None >for o, a in opts: >if o in ["-h", "--help"]: >Usage() >sys.exit() >if o in ["-o", "--output", "--out"]: >output = a >if o in ["-i", "--input", "--in"]: >input = a >if input in [".", "cwd"]: >input = os.getcwd() > > Notice the 'fixed font / proportional font' link in the top right > corner. I presume this is on the Google page. > I think they have "fixed" the problem. Great. Now people have to learn to use the fixed font choice. TJR -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
Hello again, For some strange reason Google isn't showing this so I got this from gmane sorry if I missed something. The fixed/proportional link is located on the google groups c.l.py pages. I wasn't clear at all sorry for the ambiguity. Google groups for c.l.py seems to be fixed by default, so no need to click it. Proportional still retains spaces but is less tidy. M.E.Farmer >> Terry, >> This was posted from google groups, can you see the indents? >Yes, looks good >> # code snippet >>convertpage = 0 >>form = None >>for o, a in opts: >>if o in ["-h", "--help"]: >>Usage() >>sys.exit() >>if o in ["-o", "--output", "--out"]: >>output = a >>if o in ["-i", "--input", "--in"]: >>input = a >>if input in [".", "cwd"]: >>input = os.getcwd() >> >> Notice the 'fixed font / proportional font' link in the top right >> corner. >I presume this is on the Google page. >> I think they have "fixed" the problem. >Great. Now people have to learn to use the fixed font choice. >TJR -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
Thanks for your advice.^^ I find out something special (because i don't know). I would like to retrieve data from source file into array. The data will be omited if the value is duplicated. For example, there is 3 values - 1,2,1. It will only display 1,2 after i ran the script. value = (1,2,1) while 1: users = {} byteDict = {} byteDict = users[value] users[value] = byteDict print users I think the above code cannot run properly. Any ppl knows why the value omited when it was duplicated. Many of thanks for all!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
[EMAIL PROTECTED] wrote: Thanks for your advice.^^ It would be more useful to follow them than to thank me. I find out something special (because i don't know). I would like to retrieve data from source file into array. The data will be omited if the value is duplicated. For example, there is 3 values - 1,2,1. It will only display 1,2 after i ran the script. value = (1,2,1) while 1: users = {} byteDict = {} byteDict = users[value] users[value] = byteDict print users I think the above code cannot run properly. Don't think. Be sure. Verify. Try to find out why it cannot run at all[1]. Fix this problem first. *Then* we'll happily read your next posts and try to help you fix the other problems if there are... [1] It's pretty obvious for anyone having read any python beginner tutorial, I already explained you why, and gave you a working example. If you don't read answers, don't post questions :-/ -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
I am sorry that i forgot to see the working example. Base on your example, i can show the value without missing but got the other problem. I would like to culmulate the value by users. I was rewrite your example but cannot not work. ## import sys import pprint try: f = open('data.txt', 'r') except IOError, e: print >> sys.stderr, "Cannot open file data.txt for reading : %s" %e sys.exit(1) users = {} cumdata2 = 0 cumdata3 = 0 for line in f: try: user, data1, data2 = line.strip().split('\t') except ValueError: print >> sys.stderr, "wrong file format" f.close() sys.exit(1) try: users[user].append("%s : %s" % (data1, data2)) cumdata2 = int(data2) + cumdata2 except KeyError: users[user] = ["%s : %s" % (data1, data2)] cumdata3 = int(data2) + cumdata3 f.close() print "collected data:"; pprint.pprint(users) print cumdata2 print cumdata3 ## The above example can run but the total num are wrong. Would you mind to figure out where is my problem? Thanks for your prompt help!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
[EMAIL PROTECTED] wrote: I am sorry that i forgot to see the working example. Base on your example, i can show the value without missing but got the other problem. I would like to culmulate the value by users. This is (almost) exactly the same. I was rewrite your example but cannot not work. ## import sys import pprint try: f = open('data.txt', 'r') except IOError, e: print >> sys.stderr, "Cannot open file data.txt for reading : %s" %e sys.exit(1) users = {} cumdata2 = 0 cumdata3 = 0 for line in f: try: user, data1, data2 = line.strip().split('\t') except ValueError: print >> sys.stderr, "wrong file format" f.close() sys.exit(1) try: users[user].append("%s : %s" % (data1, data2)) cumdata2 = int(data2) + cumdata2 Q1 : What do you think this will do ? except KeyError: users[user] = ["%s : %s" % (data1, data2)] cumdata3 = int(data2) + cumdata3 Q2 : What do you think this will do ? f.close() print "collected data:"; pprint.pprint(users) print cumdata2 print cumdata3 ## The above example can run but the total num are wrong. First, please post your test data set, the expected result and the actual result. Saying 'the total num is wrong' doesn't give a clue. Would you mind to figure out where is my problem? I may be wrong (pun intended), but I think you don't really understand what this code is doing, specially this part : try: users[user].append(something) except KeyError: users[user] = [something] In fact I think your problem is that you still have not read the fine manual, specially the part about dicts. Read the manual, understand the above snippet - which is a pretty common idiom in Python -, try to answer Q1 and Q2, and you should be able to work it out by yourself. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help for Python programming
Thanks for your help! I am already fix it!! Many thanks! -- http://mail.python.org/mailman/listinfo/python-list
connect to https unpossible. Please help.
Hi, i want to log via python script to https page: 'https://brokerjet.ecetra.com/at/' # But it does not work. I am using following code(see below) Has somebody any ideas? How can I get to this https page? Need I to know some infos from "provider"(certificates, etc)? Thank u very much ! sincerely mark Code: == import urllib2 theurl='https://brokerjet.ecetra.com/at/' # username = 'username' password = 'password' passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, theurl, username, password) authhandler = urllib2.HTTPBasicAuthHandler(passman) opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener) t = urllib2.urlopen('https://brokerjet.ecetra.com/at/') # Traceback (most recent call last): File "", line 1, in ? File "C:\Program Files\python233\lib\urllib2.py", line 129, in urlopen return _opener.open(url, data) File "C:\Program Files\python233\lib\urllib2.py", line 326, in open '_open', req) File "C:\Program Files\python233\lib\urllib2.py", line 306, in _call_chain result = func(*args) File "C:\Program Files\python233\lib\urllib2.py", line 908, in https_open return self.do_open(httplib.HTTPS, req) File "C:\Program Files\python233\lib\urllib2.py", line 886, in do_open raise URLError(err) urllib2.URLError: -- Highspeed-Freiheit. Bei GMX supergünstig, z.B. GMX DSL_Cityflat, DSL-Flatrate für nur 4,99 Euro/Monat* http://www.gmx.net/de/go/dsl -- http://mail.python.org/mailman/listinfo/python-list
Please help me understand this code....
Hello, I am a programmer, but not a python guy. So I am a little confused with the following python code. Specifically what does the ":" do in the array arithmetic? new_page = map[opage] old_page = map[opage^1] center = new_page[1:-1,1:-1] origcenter = array(center) center[:] = old_page[2:,2:] center += old_page[1:-1,2:] center += old_page[:-2,2:] center += old_page[2:,1:-1] center += old_page[:-2,1:-1] center += old_page[2:,:-2] center += old_page[1:-1,:-2] center += old_page[:-2,:-2] center >>= 2 center -= origcenter center -= (center>>density) Thanks!! Randy -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
"anon" <[EMAIL PROTECTED]> writes: > to do an Import on it. This is where things fail. I cannot see the > contents of my Jar. What am I missing here? That JARs are for Java and yo're using Python? -- Jorge Godoy <[EMAIL PROTECTED]> "Quidquid latine dictum sit, altum sonatur." - Qualquer coisa dita em latim soa profundo. - Anything said in Latin sounds smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
anon wrote: > Would somebody please drop me a hint, please? > Yeah, the definition of "JAR" is Java ARchive, why the hell would a Python script be able to read a JAR in the first place (truth is it is, a JAR file is nothing but a renamed ZIP, therefore the zipfile module allows you to read it's content) and -- more importantly -- import Java classes. Notice the difference between *Python* script and *Java* class? That's because they're two different languages. If you want to use Java classes and modules in a Pythonic context, you want Jython (http://www.jython.org/) not Python (http://www.python.org/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
On Sun, 05 Feb 2006 17:16:38 +0100, Xavier Morel <[EMAIL PROTECTED]> wrote: > anon wrote: >> Would somebody please drop me a hint, please? >> > Yeah, the definition of "JAR" is Java ARchive, why the hell would a > Python script be able to read a JAR in the first place You are rude to an obvious newbie here ... please keep in mind that today's stupid newbies are tomorrow's Python professionals. ... > If you want to use Java classes and modules in a Pythonic context, you > want Jython (http://www.jython.org/) not Python (http://www.python.org/) Maybe he /is/ running Jython and failed to explain that properly? If I understand things correctly, jar files are not tied to Java but to the java bytecode format -- which Java and Jython share. In either case, we'd need more information from the original poster. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
Jorgen Grahn wrote: >>Yeah, the definition of "JAR" is Java ARchive, why the hell would a >>Python script be able to read a JAR in the first place > > You are rude to an obvious newbie here ... Agreed. I don't think it was intended, but we should be cautious with our language when we address strangers... > Maybe he /is/ running Jython and failed to explain that properly? Not likely, since he wrote "python24". I think the newest Jython is 2.2a1... -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
Jorgen Grahn wrote: > You are rude to an obvious newbie here ... please keep in mind that today's > stupid newbies are tomorrow's Python professionals. > I didn't mean to be rude and apologize if that's the way it came out. > Maybe he /is/ running Jython and failed to explain that properly? > No, he explicitely stated that he's using Python 2.4 (I'm pretty sure Jython's latest release is 2.1) and SPE (which didn't handle Jython last time I tried it) > If I > understand things correctly, jar files are not tied to Java but to the java > bytecode format -- which Java and Jython share. > Yes, it's used to store/package compiled java classes (.class bytecode files) and various metadata associated to the classes (resources, ...) and therefore tied to the bytecode (or the JVM) indeed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
Xavier Yes I meant Python. I have also been using Jython and I am VERY WELL aware what a JAR is. Jython has the ability to call methods stored in classes in a JAR. I was only asking if this could be done with Python also. You ask "why the hell would a Python script be able to read a JAR..". Well, I was simply asking a newbie question. The only way to gather knowladge is by asking questions. You know, an old college proffesor I had was very knowladgeable and wise. He always took the time to answer questions, no matter how 'stupid' they would sound. One can make a bigger impression on folks by stepping down a couple of steps and give a polite answer. I mean no disrespect, just a suggestion when you post answers to folks like me who are just getting started with a new language... regards "Xavier Morel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > anon wrote: >> Would somebody please drop me a hint, please? >> > Yeah, the definition of "JAR" is Java ARchive, why the hell would a Python > script be able to read a JAR in the first place (truth is it is, a JAR > file is nothing but a renamed ZIP, therefore the zipfile module allows you > to read it's content) and -- more importantly -- import Java classes. > > Notice the difference between *Python* script and *Java* class? That's > because they're two different languages. > If you want to use Java classes and modules in a Pythonic context, you > want Jython (http://www.jython.org/) not Python (http://www.python.org/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
On Sun, 5 Feb 2006 10:41:51 -0500 "anon" <[EMAIL PROTECTED]> wrote: > Newbie to Python and I have a question please. I am using > Windows XP, SPE 0.8.2.a and Python24. I have done this: > > import sys > print sys.path > > no problem there, sys imports just fine. I have a folder > that I called c\JavaProjects\PythonTesting and it shows > up in the output from sys.path above. I have dropped a > very simple Jar in that folder and I have attempted to do > an Import on it. This is where things fail. I cannot see > the contents of my Jar. What am I missing here? As others have pointed out, ".jar" is going to be Java bytecode, and from that strange looking path (was, I assume supposed to be "C:\JavaProjects\PythonTesting"), it looks very much like you really wanted to be using Jython (a.k.a "Java Python") rather than Python (a.k.a. "C Python"). Perhaps you have both Jython and Python 2.4 installed and you are launching the latter when you meant the former? In any case, C Python cannot load Java classes (that's the main raison d'etre for Jython). -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing a class, please help...
anon <[EMAIL PROTECTED]> wrote: > Xavier > > Yes I meant Python. I have also been using Jython and I am VERY WELL aware > what a JAR is. Jython has the ability to call methods stored in classes in > a JAR. I was only asking if this could be done with Python also. Classic Python is able to import Python modules from a .zip file; it would be a reasonably easy tweak to allow the extension to be .jar or .foo or .zap as well as .zip -- but they'd still have to be Python modules. Java classes use a completely different bytecode from Classic Python: if you need to access such JVM bytecode, use Jython instead. Alex -- http://mail.python.org/mailman/listinfo/python-list
Struggling with this concept please help
Hello everyone I know many have helped but I cannot get this to work out correctly. I cannot use BeautifulSoup at all. I need to: Parse the HTML and extracting all the links, convert them to IP addresses, and build a list of all these IP addresses, thwn I need to sort the list and remove the duplicates so that unit testing will work. Please help I have never done python before and I can't seem to get the hang of it. """ Module to print IP addresses of tags in web file containing HTML >>> showIPnums('http://22c118.cs.uiowa.edu/uploads/easy.html') ['0.0.0.0', '128.255.44.134', '128.255.45.54'] >>> showIPnums('http://22c118.cs.uiowa.edu/uploads/pytorg.html') ['0.0.0.0', '128.255.135.49', '128.255.244.57', '128.255.30.11', '128.255.34.132', '128.255.44.51', '128.255.45.53', '128.255.45.54', '129.255.241.42', '64.202.167.129'] """ import htmllib import formatter import urllib import socket from urlparse import urlparse class HTML_Parser(htmllib.HTMLParser): def __init__(self): htmllib.HTMLParser.__init__(self, formatter.AbstractFormatter(formatter.NullWriter())) def start_a(self, args): for key, value in args: if key.lower() == 'href': global listURL def showIPnums(URL): parser = HTML_Parser() connect = urllib.urlopen(URL) data = connect.read() parser.feed(data) parser.close() connect.close() if __name__ == '__main__': import doctest, sys doctest.testmod(sys.modules[__name__]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
En Mon, 19 Mar 2007 16:00:04 -0300, Al <[EMAIL PROTECTED]> escribió: > I looked in the pycron.log file, and I noticed that for the entires of > my new job, I see "rc=4" and the end of each line. All other jobs have > "rc=0" at the end of the line. I assume then, that rc=4 is a reference > to an error code of some kind, but there is no information on this in > the readme.txt, at the pycron website, or here in groups. > > Does anyone know how to troubleshhot this? Thanks in advance. Contacting the author? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
heh... didn't think about that... thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
Here's something else you should consider: Look at the source code of pycron. I just downloaded it. Much to my surprise, this is implemented in about 115 lines of code. In particular, look at the run() function. You should try adding a try-except block around the system call to get a hint as to where the problem lies: try: os.system('start ' + command) except: print "Unexpected error to catch:", sys.exc_info()[0] I've been trying to use it myself (on a Mac) since I saw you mention it on the mailing list. I'm also having problems using pycron. Email me directly if you figure out the problem. I'll do the same for you. Gabriel Genellina wrote: En Mon, 19 Mar 2007 16:00:04 -0300, Al <[EMAIL PROTECTED]> escribió: I looked in the pycron.log file, and I noticed that for the entires of my new job, I see "rc=4" and the end of each line. All other jobs have "rc=0" at the end of the line. I assume then, that rc=4 is a reference to an error code of some kind, but there is no information on this in the readme.txt, at the pycron website, or here in groups. Does anyone know how to troubleshhot this? Thanks in advance. Contacting the author? -- Shane Geiger IT Director National Council on Economic Education [EMAIL PROTECTED] | 402-438-8958 | http://www.ncee.net Leading the Campaign for Economic and Financial Literacy begin:vcard fn:Shane Geiger n:Geiger;Shane org:National Council on Economic Education (NCEE) adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States email;internet:[EMAIL PROTECTED] title:IT Director tel;work:402-438-8958 x-mozilla-html:FALSE url:http://www.ncee.net version:2.1 end:vcard -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
Shane, I figured it out... Pycron does not work with mapped drives. My script was supposed to copy files from a mapped drive to a local folder... I had set up my batch command as copy M:\foldername\*.*, where M: is a mapped drive pointing to the network share; M: is defined on the PC running the Pycron service of course. I changed it to read copy \\servername\shares\foldername\*.* and now everything works correctly. Al -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
En Sun, 25 Mar 2007 10:17:47 -0300, Al <[EMAIL PROTECTED]> escribió: >I figured it out... Pycron does not work with mapped drives. My > script was supposed to copy files from a mapped drive to a local > folder... I had set up my batch command as copy M:\foldername\*.*, > where M: is a mapped drive pointing to the network share; M: is > defined on the PC running the Pycron service of course. I changed it > to read copy \\servername\shares\foldername\*.* and now everything > works correctly. Mapped drives are per-user. Usually, services run under the LOCAL_SYSTEM account, not using the currently logged user (because they may start even before any user is logged). If you want the service to have access to your mapped drives, use the service control panel to make it run under another account. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycron for windows - please help
> Mapped drives are per-user. Usually, services run under the LOCAL_SYSTEM > account, not using the currently logged user (because they may start even > before any user is logged). If you want the service to have access to your > mapped drives, use the service control panel to make it run under another > account. Pycron runs under our domain admin account, and the computer on which it runs is always on. I tried changing the account anyway, but no luck. -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Ray wrote: > hi, I have a question about how to use .grid_forget (in python/TK) > > I need to work on grid repeatly. everytime when a button is pressed, > the rows of grid is different. such like, first time, it generate 10 > rows of data. > 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data > every time. how can I do it? by grid_forger()?, then would anyone can > help on > how to use grid_forget() > the sample code as following: I'm not sure if it solves your problem but this modification of your code at least *looks* like it works better. The entries are completely destroyed so that the next time you call the function they can be recreated. The trick I am using is to use a list in the arguments of the function but that is a bit of a hack, the list 'remembers' its state from the last time the function was called, I think one should use classes for bookkeeping such things instead. from Tkinter import * def mygrid(text,M = []): how to use grid_forget() to clean the grid??### while M: x = M.pop() x.destroy() rows = [] count=int(text) for i in range(count): cols = [] for j in range(4): e = Entry(frame3, relief=RIDGE) M.append(e) e.grid(row=i, column=j, sticky=NSEW) e.insert(END, '%d.%d' % (i, j)) cols.append(e) rows.append(cols) root=Tk() frame1=Frame(root, width=150, height=100) frame1.pack() text=Entry(frame1) text.pack(side=LEFT) button=Button(frame1, text='generate grid', command=(lambda: mygrid(text.get( button.pack() frame2=Frame(root, width=150, height=100) frame2.pack() button2=Button(frame2, text='exit', command=root.quit) button2.pack() frame3=Frame(root, width=150, height=300) frame3.pack() root.mainloop() A. -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Ray wrote: > hi, I have a question about how to use .grid_forget (in python/TK) > > I need to work on grid repeatly. everytime when a button is pressed, > the rows of grid is different. such like, first time, it generate 10 > rows of data. > 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data > every time. how can I do it? by grid_forger()?, then would anyone can > help on > how to use grid_forget() > the sample code as following: > > #begin of program### > > from Tkinter import * > def mygrid(text): > how to use grid_forget() to clean the grid??### > rows = [] > count=int(text) > for i in range(count): > cols = [] > for j in range(4): > e = Entry(frame3, relief=RIDGE) > e.grid(row=i, column=j, sticky=NSEW) > e.insert(END, '%d.%d' % (i, j)) > cols.append(e) > rows.append(cols) > > > root=Tk() > > frame1=Frame(root, width=150, height=100) > frame1.pack() > > text=Entry(frame1) > text.pack(side=LEFT) > > button=Button(frame1, text='generate grid', command=(lambda: > mygrid(text.get( > > button.pack() > > frame2=Frame(root, width=150, height=100) > frame2.pack() > > button2=Button(frame2, text='exit', command=root.quit) > button2.pack() > > frame3=Frame(root, width=150, height=300) > frame3.pack() > > root.mainloop() > > #end of program### Using grid_forget() is probably optimization overkill, but may be handy for slower computers where you can watch the widgets appear one by one (older than about 5 years--for example original mac ibook). Also, you should get a good book on Tkinter because your design here will pretty difficult to maintain and is not very flexible. But...if you want to know how it might be done with grid_forget using the code you already have (i.e. making widgets only if necessary): #START# from Tkinter import * from tkMessageBox import showerror def mygrid(text): how to use grid_forget() to clean the grid??### numrows = len(frame3.rows) try: count=int(text) except: showerror('Entry Error', '''Hey, "%s" don't make an int, Fool!''' % text, parent=frame3) return 'break' for i in range(count): if i < numrows: cols = frame3.rows[i] else: cols = [Entry(frame3, relief=RIDGE) for j in range(4)] frame3.rows.append(cols) for j in range(4): e = cols[j] e.grid(row=i, column=j, sticky=NSEW) e.delete(0,END) e.insert(END, '%d.%d' % (i, j)) for i in range(i+1, numrows): for e in frame3.rows[i]: e.grid_forget() root=Tk() frame1=Frame(root, width=150, height=100) frame1.pack() text=Entry(frame1) text.pack(side=LEFT) button=Button(frame1, text='generate grid', command=(lambda: mygrid(text.get( button.pack() frame2=Frame(root, width=150, height=100) frame2.pack() button2=Button(frame2, text='exit', command=root.quit) button2.pack() frame3=Frame(root, width=150, height=300) # adding an attribute here frame3.rows = [] frame3.pack() root.mainloop() #END# Notice also the necessity for the "e.delete(0, END)" line to get the desired text in the entries. Also demonstrated is how to handle poor input. *Note* Remember to always call the user "Fool" when he does something stupid. James -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Hi, Thanks for the help! Anton Vredegoor wrote: > Ray wrote: > >> hi, I have a question about how to use .grid_forget (in python/TK) >> >> I need to work on grid repeatly. everytime when a button is pressed, >> the rows of grid is different. such like, first time, it generate 10 >> rows of data. >> 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data >> every time. how can I do it? by grid_forger()?, then would anyone can >> help on >> how to use grid_forget() >> the sample code as following: > > I'm not sure if it solves your problem but this modification of your > code at least *looks* like it works better. The entries are completely > destroyed so that the next time you call the function they can be > recreated. > > The trick I am using is to use a list in the arguments of the function > but that is a bit of a hack, the list 'remembers' its state from the > last time the function was called, I think one should use classes for > bookkeeping such things instead. > > from Tkinter import * > > def mygrid(text,M = []): > how to use grid_forget() to clean the grid??### > while M: > x = M.pop() > x.destroy() > rows = [] > count=int(text) > for i in range(count): > cols = [] > for j in range(4): > e = Entry(frame3, relief=RIDGE) > M.append(e) > e.grid(row=i, column=j, sticky=NSEW) > e.insert(END, '%d.%d' % (i, j)) > cols.append(e) > rows.append(cols) > > > root=Tk() > > frame1=Frame(root, width=150, height=100) > frame1.pack() > > text=Entry(frame1) > text.pack(side=LEFT) > > button=Button(frame1, text='generate grid', command=(lambda: > mygrid(text.get( > > button.pack() > > frame2=Frame(root, width=150, height=100) > frame2.pack() > > button2=Button(frame2, text='exit', command=root.quit) > button2.pack() > > frame3=Frame(root, width=150, height=300) > frame3.pack() > > root.mainloop() > > A. -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Hi, Thanks for the help. I was trying to find a book "Python TK" something on last Friday. but didn't find it :-) I know those codes are in poor design, because I wrote those sample code to show the idea about what I need. the real code is working with mysql. however, I'm really new in python. (I start learning it on last Wednesday). Thanks again for the help! Ray James Stroud wrote: > > > Using grid_forget() is probably optimization overkill, but may be handy > for slower computers where you can watch the widgets appear one by one > (older than about 5 years--for example original mac ibook). Also, you > should get a good book on Tkinter because your design here will pretty > difficult to maintain and is not very flexible. > > But...if you want to know how it might be done with grid_forget using > the code you already have (i.e. making widgets only if necessary): > > > #START# > from Tkinter import * > from tkMessageBox import showerror > def mygrid(text): > how to use grid_forget() to clean the grid??### > numrows = len(frame3.rows) > try: > count=int(text) > except: > showerror('Entry Error', > '''Hey, "%s" don't make an int, Fool!''' % text, > parent=frame3) > return 'break' > for i in range(count): > if i < numrows: > cols = frame3.rows[i] > else: > cols = [Entry(frame3, relief=RIDGE) for j in range(4)] > frame3.rows.append(cols) > for j in range(4): > e = cols[j] > e.grid(row=i, column=j, sticky=NSEW) > e.delete(0,END) > e.insert(END, '%d.%d' % (i, j)) > for i in range(i+1, numrows): > for e in frame3.rows[i]: > e.grid_forget() > > > root=Tk() > > frame1=Frame(root, width=150, height=100) > frame1.pack() > > text=Entry(frame1) > text.pack(side=LEFT) > > button=Button(frame1, text='generate grid', command=(lambda: > mygrid(text.get( > > button.pack() > > frame2=Frame(root, width=150, height=100) > frame2.pack() > > button2=Button(frame2, text='exit', command=root.quit) > button2.pack() > > frame3=Frame(root, width=150, height=300) > # adding an attribute here > frame3.rows = [] > frame3.pack() > > root.mainloop() > #END# > > Notice also the necessity for the "e.delete(0, END)" line to get the > desired text in the entries. > > Also demonstrated is how to handle poor input. > > *Note* > Remember to always call the user "Fool" when he does something stupid. > > > James -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Hello, Ray schrieb: > Hi, Thanks for the help. > > > I was trying to find a book "Python TK" something on last Friday. > but didn't find it :-) > There is only one printed book, all the details here: http://wiki.python.org/moin/GuiBooks HTH Hertha -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Hi Anton, Thanks again. This is what I need! my problem already solved. Ray Anton Vredegoor wrote: > Ray wrote: > >> hi, I have a question about how to use .grid_forget (in python/TK) >> >> I need to work on grid repeatly. everytime when a button is pressed, >> the rows of grid is different. such like, first time, it generate 10 >> rows of data. >> 2nd time, it maybe only 5 rows. so I need a way to RESET the grid data >> every time. how can I do it? by grid_forger()?, then would anyone can >> help on >> how to use grid_forget() >> the sample code as following: > > I'm not sure if it solves your problem but this modification of your > code at least *looks* like it works better. The entries are completely > destroyed so that the next time you call the function they can be > recreated. > > The trick I am using is to use a list in the arguments of the function > but that is a bit of a hack, the list 'remembers' its state from the > last time the function was called, I think one should use classes for > bookkeeping such things instead. > > from Tkinter import * > > def mygrid(text,M = []): > how to use grid_forget() to clean the grid??### > while M: > x = M.pop() > x.destroy() > rows = [] > count=int(text) > for i in range(count): > cols = [] > for j in range(4): > e = Entry(frame3, relief=RIDGE) > M.append(e) > e.grid(row=i, column=j, sticky=NSEW) > e.insert(END, '%d.%d' % (i, j)) > cols.append(e) > rows.append(cols) > > > root=Tk() > > frame1=Frame(root, width=150, height=100) > frame1.pack() > > text=Entry(frame1) > text.pack(side=LEFT) > > button=Button(frame1, text='generate grid', command=(lambda: > mygrid(text.get( > > button.pack() > > frame2=Frame(root, width=150, height=100) > frame2.pack() > > button2=Button(frame2, text='exit', command=root.quit) > button2.pack() > > frame3=Frame(root, width=150, height=300) > frame3.pack() > > root.mainloop() > > A. -- http://mail.python.org/mailman/listinfo/python-list
Re: TK-grid problem, please help
Hertha Steck wrote: > Hello, > > Ray schrieb: > >> Hi, Thanks for the help. >> >> >> I was trying to find a book "Python TK" something on last Friday. >> but didn't find it :-) >> > > There is only one printed book, all the details here: > > http://wiki.python.org/moin/GuiBooks > > HTH > Hertha This is inaccurate. There is only one book listed in the wiki. Python Programming by Mark Lutz has an excellent Tkinter section as well as an *incredible* amount of other information. Also, it has recently been updated. It is probably the most relevant book for making a complete transition from novice python programmer to expert python programmer. James -- http://mail.python.org/mailman/listinfo/python-list
"tkinter module not found" please help
I'm trying to install python2.5 on my computer(os Fedora 5). My problem is that I'm unable to get the tkinter module loaded into python. I've tried the solution here:"wiki.python.org/moin/TkInter" but am unsure as how to modify my setup.py script. I have installed the latest versions of tcl/tk (8.4.14) twice as well as installing python again. Everything is installed in the default location but still no luck. Does anyone have any ideas? Thank you. -- http://mail.python.org/mailman/listinfo/python-list
While loop with "or"? Please help!
Hmm, my while loop with "or" doesn't seem to work as I want it to... How do I tell the while loop to only accept "Y" or "y" or "N" or "n" input from the str(raw_input)? Thank's in advance! Snippet of code: import os def buildfinder(): os.system("CLS") GameRoot = os.getenv("GAME_ROOT") + "\\" print "Do you want to use " + GameRoot + " as your source directory?" usr = str(raw_input('Y/N: ')) return usr #Runs the buildfinder function usrinp = buildfinder() def buildwhiler(): while usrinp != "y" or "Y" or "N" or "n": PROBLEM print "Enter Y or N!" usr = str(raw_input('Y/N: ')) else: code continues -- http://mail.python.org/mailman/listinfo/python-list
Please help about an instance var
>>> from UserDict import UserDict >>> d = {1:2,3:4,5:6} >>> d1 = UserDict(d) >>> d1 {1: 2, 3: 4, 5: 6} >>> d1.data {1: 2, 3: 4, 5: 6} Here why both d1 and d1.data have the same values?As shown below,they're different types. >>> type(d1) >>> type(d1.data) Please help.Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Please help! win32 com_error 'Exception occurred'
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello world.') The resulting debug trace is: PythonWin 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "C:\PROGRA~1\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\PROGRA~1\Python23\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\PROGRA~1\Python23\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 631, in run exec cmd in globals, locals File "C:\yakitome\test\examples\ex1.py", line 4, in ? tts.Speak('Hello world.') File "C:\PROGRA~1\Python23\Lib\site-packages\pyTTS\sapi.py", line 213, in Speak self.speech.Speak(text, flagsum) File "C:\Program Files\Python23\lib\site-packages\win32com\gen_py\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x0.py", line 2637, in Speak , Flags) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147201015), None) >>> The system does not have a sound card --- could that be an issue? My head is about to explode trying to solve this problem, so your help and suggestions will be much appreciated.-- http://mail.python.org/mailman/listinfo/python-list
Please help on Binary file manipulation
Hi all I have a binary file of about 600kbytes - I want to break it up in file chunks of 1085 bytes - every file must have a new file name. The data is binary video frames (370 frames) - I want to play the data back into an embedded system frame/file by file. I am a complete Python newby - but have C/C++ skills. Please supply/help me with an snippet or example Thanks Pieter *** Disclaimer: The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. Any review, retransmission, dissemination, copying, disclosure or other use of, or taking of any action in reliance upon, this information by person or entities other then the intended recipient is prohibited. If you have received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and return and/or destroy the original message and all copies from any computer. Denel (Pty) Ltd exercises no editorial control over e-mail messages originating in the organisation and does not accept any responsibility for either the contents of the message or any copyright laws that may have been violated by the person sending this message. Denel (Pty) Ltd is neither liable for the proper and complete transmission of the information contained in this communication nor any delay in its receipt. This message should not be copied or used for any purpose other than intended, nor should it be disclosed to any other person. *** -- http://mail.python.org/mailman/listinfo/python-list
simple dbus python problem ... please help
Hi, I have this sample python script from the hal sources, but it doesn't work for me. This is despite other example python scripts I have to help me are working fine. The problem is that this script is the closet to what it is I actually want to learn to do. The error is: Traceback (most recent call last): File "./dbus-3.py", line 6, in ? hal_service = bus.get_service ('org.freedesktop.Hal') AttributeError: 'SystemBus' object has no attribute 'get_service' The script is as follows: #!/usr/bin/python import dbus bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM) hal_service = bus.get_service ('org.freedesktop.Hal') hal_manager = hal_service.get_object ('/org/freedesktop/Hal/Manager', 'org.freedesktop.Hal.Manager') volume_udi_list = hal_manager.FindDeviceByCapability ('volume') for udi in volume_udi_list: volume = hal_service.get_object (udi, 'org.freedesktop.Hal.Device') device_file = volume.GetProperty ('block.device') fstype = volume.GetProperty ('volume.fstype') storage_udi = volume.GetProperty ('block.storage_device') storage = hal_service.get_object (storage_udi, 'org.freedesktop.Hal.Device') drive_type = storage.GetProperty ('storage.drive_type') print 'udi=%s device_file=%s fstype=%s drive_type=%s'%(udi, device_file, fstype, drive_type) Documentation on this stuff is extremely thin on the ground, so links to any good resources other than those at freedesktop.org would be most appreciated! All I really want to do is have a nice routine to do the following: 1. check whether or not a user has a dvd drive. 2. check whether a disc is in it. 3. if there is a disc in the drive, check the various properties relating to it. Surely it cannot be that hard to get enough information to work out how to do that! Thanks for reading :) -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb problem with mod_python, please help
> MySQLdb is working fine at command line, however when I tried to use > it with mod_python, it give me a "server not initialized" error. Maybe its this problem? http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb problem with mod_python, please help
Damjan <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > MySQLdb is working fine at command line, however when I tried to use > > it with mod_python, it give me a "server not initialized" error. > > Maybe its this problem? > http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.013.htp yep! that's the culprit. I havent' recompile php, but by removing loadmodule php, mod_python+mysql worked. Thank you very much Damjan. -- http://mail.python.org/mailman/listinfo/python-list
re: Please help -- Pmw PanedWidget inside ScrolledFrame
Almost forgot, here's the code sample: #!/usr/bin/env python import sys, os, Tkinter, types, tkFont, Pmw def makeResizable(widget): for i in range(0, widget.grid_size()[0]): widget.columnconfigure(i, weight=1) for i in range(0, widget.grid_size()[1]): widget.rowconfigure(i, weight=1) def main(): root = Tkinter.Tk() root.geometry("500x500+0+0") Pmw.initialise(root) scrolledFrame = Pmw.ScrolledFrame(root, usehullsize=1, borderframe=0, hscrollmode='static', vscrollmode='static') scrolledFrame.grid(row=0, rowspan=20, column=0, columnspan=20, sticky='nsew') panes = Pmw.PanedWidget(scrolledFrame.interior(), orient='horizontal', hull_borderwidth=2, hull_relief='sunken') panes.grid(row=0, rowspan=20, column=0, columnspan=20, sticky='nsew') for i in range(5): pane = panes.add("pane"+str(i), size=1/5.0) button = Tkinter.Button(pane, text="This Is A Very Long Name For A Button") button.grid(row=0, rowspan=1, column=i, columnspan=1, sticky='nsew') makeResizable(root) makeResizable(scrolledFrame.interior()) makeResizable(panes) root.mainloop() if __name__=='__main__': main() -- http://mail.python.org/mailman/listinfo/python-list
Re: connect to https unpossible. Please help.
"Mark Delon" <[EMAIL PROTECTED]> wrote: > >i want to log via python script to https page: > >'https://brokerjet.ecetra.com/at/' ># >But it does not work. > >I am using following code(see below) > >Has somebody any ideas? >How can I get to this https page? >Need I to know some infos from "provider"(certificates, etc)? >Thank u very much ! You are trying to set this up to use HTTP BasicAuth authorization, but this page is not using HTTP authorization. You can recognize HTTP authorization by the separate browser window that pops up to ask for your username and password. In this case, the username and password fields are just ordinary fields on a form. What you need to do is read the HTTP on that page, and figure out how to send a URL containing values for those fields. In this case, the form data goes to https://brokerjet.ecetra.com/at/welcome/loginaction.phtml, and you'll need to encode 'login' and 'pwd' fields in the POST data. However, that isn't the end of your trouble. That page will almost certainly send you a cookie, which you will need to send back with every request. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: connect to https unpossible. Please help.
Hi Tim, really than u very much! I think u have helped me! I will try, that what u said. I have found probably simplier solution. Is it so? ...but without success:-(. I want to download some URLs via python script. With some URLs I have success with some NOT. Why? I do following: === 1. Login to https://brokerjet.ecetra.com/at/welcome/register/loginpage.phtml via Mozzila browser 2. I try to download some URLs using cookies: see script bellow: 3. Some pages works (e.g. news, but on some pages I get: -- Traceback (most recent call last): File "test_stock.py", line 11, in ? r = opener.open("https://brokerjet.ecetra.com/at/trading/wt.phtml?isin=NL24&exid=ETR";) File "C:\Programme\Python24\lib\urllib2.py", line 358, in open response = self._open(req, data) File "C:\Programme\Python24\lib\urllib2.py", line 376, in _open '_open', req) File "C:\Programme\Python24\lib\urllib2.py", line 337, in _call_chain result = func(*args) File "C:\Programme\Python24\lib\urllib2.py", line 1029, in https_open return self.do_open(httplib.HTTPSConnection, req) File "C:\Programme\Python24\lib\urllib2.py", line 996, in do_open raise URLError(err) urllib2.URLError: Details- Script: = I make login via Mozilla browser import os, cookielib, urllib2 cj = cookielib.MozillaCookieJar() os.environ['HOME']= r"C:\tmp\COOKIE" cj.load(os.path.join(os.environ["HOME"], "cookies.txt")) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # first URLs download works r = opener.open("http://brokerjet.ecetra.com/at/news/index.phtml?notation=7536885";) # second URLs download DOES NOT work ... WHY? r = opener.open("https://brokerjet.ecetra.com/at/trading/wt.phtml?isin=NL24&exid=ETR";) # h = r.readlines() g = open("test.html","w") g.writelines(h) g.close() os.system("test.html") Thans realy for all ideas! sincerely mark > --- Ursprüngliche Nachricht --- > Von: Tim Roberts <[EMAIL PROTECTED]> > An: python-list@python.org > Betreff: Re: connect to https unpossible. Please help. > Datum: Fri, 21 Oct 2005 06:05:45 GMT > > "Mark Delon" <[EMAIL PROTECTED]> wrote: > > > >i want to log via python script to https page: > > > >'https://brokerjet.ecetra.com/at/' > ># > >But it does not work. > > > >I am using following code(see below) > > > >Has somebody any ideas? > >How can I get to this https page? > >Need I to know some infos from "provider"(certificates, etc)? > >Thank u very much ! > > You are trying to set this up to use HTTP BasicAuth authorization, but > this > page is not using HTTP authorization. You can recognize HTTP > authorization > by the separate browser window that pops up to ask for your username and > password. > > In this case, the username and password fields are just ordinary fields on > a form. What you need to do is read the HTTP on that page, and figure out > howfiues for those fields. In this case, the > form data goes to > https://brokerjet.ecetra.com/at/welcome/loginaction.phtml, and you'll need > to encode 'login' and 'pwd' fields in the POST data. > > However, that isn't the end of your trouble. That page will almost > certainly send you a cookie, which you will need to send back with every > request. > -- > - Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Telefonieren Sie schon oder sparen Sie noch? NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help me understand this code....
The : is used in Python for slice notation, which is explained pretty thoroughly in the Python tutorial, specifically at: http://www.python.org/doc/2.4/tut/node5.html -- http://mail.python.org/mailman/listinfo/python-list
MVC programming with python (newbie) - please help
I'd appreciate some experience from the gurus out there to help me understand how to implement MVC design in python code. Entry number 5 on the wxpython wiki at http://wiki.wxpython.org/index.cgi/BuildingControls discusses MVC design in building reusable controls. The author (Terrel Shumway) suggests that instead of: quote: class MyCoolListControl(...): def __init__(self,parent,id,choices): ... def InsertItem(...): def AppendItem(...): where choices is a static list, do something like this class ListDataModel: """ a minimal model interface to be used by MyCoolListControl """ def __len__(self): """ return the number of items in the list """ def __getitem__(self,index): """ return the specified item """ # consider notifications for observers (e.g. the list control) # allow the user to define whatever mutators are appropriate class MyCoolListControl(...): def __init__(self,parent,id,model): ... def [GS]etModel(self,model): ... This allows the user (programmer) to store the data the way he thinks is best, rather than having to copy the data into your structure whenever it changes. It also reduces the need for kludges like [GS]etItemData for maintaining association of the real data with its currently displayed string representation. endquote The author refers to mvctree.py in wxPython as an example of MVC design. However I'm still too green so I find that particular example too complex and I'm not understanding the separation the author is recommending. Can anyone explain to me further the simple example above and/or supply a simple example of their own? At some level I feel like there's a benefit but I'm failing to grasp it, and how to implement it. If I understand correctly then in the future for example I could completely change how data is stored in the class ListDataModel and not require a change in class MyCoolListControl. Say, hypothetically, I wanted to implement ListDataModel using a dictionary rather than, more naturally, a list, where the "list" data structure is implemented as a dictionary and the list entries correspond to dictionary keys (dictionary values are not used in this case). Then if I understand the MVC concept, class MyCoolListControl need not change at all. If that's true then that's really cool. But I don't get how that works. I think I need a little further expansion of the example or an alternative (20-30 liner) that I can work through. The question arises in the context of wanting to build a dialog with a tree control that presents projects and studys as a tree and allows selection of projects and studies as required by the user. I want to parse a file with contents as follows: BEGIN PROJECT "mpi6_0" STUDY "Cyc0302_0" cyc0302_beanoz_x1.sdy STUDY "Cyc0305_0" cyc0305_beanoz_x1.sdy STUDY "Cyc0308_0" cyc0308_beanoz_x1.sdy STUDY "Cyc0311_0" cyc0311_beanoz_x1.sdy STUDY "Cyc0314_0" cyc0314_beanoz_x1.sdy END PROJECT BEGIN PROJECT "mpi6_1" STUDY "Cyc0302_1" cyc0302_beanoz_x1.sdy STUDY "Cyc0305_1" cyc0305_beanoz_x1.sdy STUDY "Cyc0308_1" cyc0308_beanoz_x1.sdy STUDY "Cyc0311_1" cyc0311_beanoz_x1.sdy STUDY "Cyc0314_1" cyc0314_beanoz_x1.sdy END PROJECT ... I have wriiten a class as follows that extracts the data from the file. import os class ProjectFileDecoder: """ parse project file to obtain project names and associated studies and study files """ def __init__(self, file): self.projects = {} self.parse_file(file) def parse_file(self, file): f = open(file, 'r') dir = os.path.split(file) while 1: line = f.readline() if 'BEGIN PROJECT' in line: proj_name = line.strip().split('"')[1] self.projects[proj_name] = {} elif 'STUDY' in line: study_name = (line.strip().split('"'))[1].strip() study_file = dir[0] + '/' + (line.strip().split('"'))[2].strip() self.projects[proj_name][study_name] = study_file elif not len(line): f.close() break def getProjectNames(self): return self.projects.keys() def getStudyNames(self): return [self.projects[i].keys() for i in self.getProjectNames()] def getStudyFiles(self): return [self.projects[i].values() for i in self.getProjectNames()] At some level this seems to me like the class ListDataModel above. I just need to make a MyTreeControl class. However here GS(et) routines are implemented in the ProjectFileDecoder class (data model?) whereas in the earlier advice they are in class MyCoolListControl. So I'm not understanding how data gets from the DataModel class to the ListControl class. After all the words I've said, I think that's the core misunderstanding I have. Hope someone can help clear that up for me. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Struggling with this concept please help
"George" <[EMAIL PROTECTED]> wrote: > Hello everyone I know many have helped but I cannot get this to work > out correctly. I cannot use BeautifulSoup at all. I need to: > [snipped] What do you mean you cannot use BeautifulSoup ? You cannot download it, install it, import it, or you are not allowed to use it because it's a homework ? If it's the latter, I doubt that you'll get a solution spelled out for you in this group. George -- http://mail.python.org/mailman/listinfo/python-list
Re: Struggling with this concept please help
Not allowed to use Beautiful Soup because of the very important built ins that is provides that makes it very simple to complete this problem. Not my choice . This is a review question for our final in two months and I just want to get things going so I can try to understand things better. Please help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Struggling with this concept please help
George wrote: > Not allowed to use Beautiful Soup because of the very important built > ins that is provides that makes it very simple to complete this > problem. Not my choice . This is a review question for our final in two > months and I just want to get things going so I can try to understand > things better. Please help. Post your code. Nobody is giving you the solution to your problem - it's your task, after all! But we'd happily comment on your trials. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Struggling with this concept please help
* George <[EMAIL PROTECTED]> [2005-09-25 16:20]: > Hello everyone I know many have helped but I cannot get this to work > out correctly. > Please help I have never done python before and I can't seem to get the > hang of it. You posted code. Is what's in the docstring actual output? If so, what isn't it doing that you want it to? If it's not working correctly, what's it doing? Just saying "I cannot get this to work" doesn't give us much to go on. If you want specific help, be sure to: 1) post actual code 2) explain what you expect it to do 3) post actual output (or traceback) 4) ask a specific question about what you don't understand about item 3. Even though we know this is schoolwork, I'm OK with offering you a hint or answering a specific question. -John -- http://mail.python.org/mailman/listinfo/python-list
please help me is sms with python
hi please i need your help . how can i send sms from pc(windows xp) to mobile symbian 60 6630 by python i need your help please i hope you answer me as fast as u can thanks in advance.. -- http://mail.python.org/mailman/listinfo/python-list
Please help me to resolve this issue
Hello everyone, I am pretty new in python. Please give me any idea about this issue: There is a function like this in my c dll: typedef void (WINAPI *myCallBack) (unsigned int myarg1, unsigned int myarg2) bool myfunc(myCallBack mycall) In my python code, I was able to access other functions in the dll, but I have no idea how to call myfunc() because of WINAPI argument. Thanks in advance. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list