Re: Registration Open for South Florida Software Symposium 2007
It is just a good news. -- http://mail.python.org/mailman/listinfo/python-list
urllib equivalent for HTTP requests
Hello everyone, I understand that urllib and urllib2 serve as really simple page request libraries. I was wondering if there is a library out there that can get the HTTP requests for a given page. Example: URL: http://www.google.com/test.html Something like: urllib.urlopen('http://www.google.com/ test.html').files() Lists HTTP Requests attached to that URL: => http://www.google.com/test.html => http://www.google.com/css/google.css => http://www.google.com/js/js.css The other fun part is the inclusion of JS within
PYTHON
PLEASE LEARN ME PYTHON -- http://mail.python.org/mailman/listinfo/python-list
Python Windows release and encoding
Hi, I am working on Linux; a friend of mine sends to me python files from his Windows release. He uses the editor coming with the release; he runs his code from the editor by using a menu (or some F5 key I think). He doesn't declare any encoding in his source file; when I want to try his code, I have an error since he obviously uses non-ascii characters. As far as I can see, he uses utf8 without knowing it. I add the UTF8 declaration, run the code, and everything is fine. Then I tell him to add the utf-8 declaration; but now he has an error when running his file from the Windows editor. Finally, he told me he could run the file by declaring the latin-1 encoding. But I want to understand exactly: a) what is the encoding used by the editor coming in the Windows release? b) why doesn't he need to declare the encoding (I need it on Linux for the very same files)? Best regards, ak. -- http://mail.python.org/mailman/listinfo/python-list
Error 32 - Broken Pipe . Please Help!!
Error: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/monitor.py", line 575, in run already_pickled=True) File "/usr/lib/python2.7/dist-packages/spyderlib/utils/bsdsocket.py", line 24, in write_packet sock.send(struct.pack("l", len(sent_data)) + sent_data) error: [Errno 32] Broken pipe Code : #code s=1 f=0 c=0 for i in range (1,100): c=0 for j in (1,i): s+=j c=0 for k in range(1,(s/2+1)): #print s t=s%k if t==0: c+=1 if c>=5: f=1 print s break print s #code ends. The program is runnning. It has been more than 10 minutes ( currently). Should I raise my hopes for an answer ? -- http://mail.python.org/mailman/listinfo/python-list
Re: please i need explanation
Hi! Since there is no stated question, I need to guess: n -= 1 (instead of "f -= 1") should work. Or maybe the question was a totally different one... -Kimmo 11.01.2013 17:35, kwakukwat...@gmail.com wrote: def factorial(n): if n<2: return 1 f = 1 while n>= 2: f *= n f -= 1 return f -- http://mail.python.org/mailman/listinfo/python-list
Keyboard hook in linux
Hi! I am working on a small console app for linux. The idea is to display some sensor values and the screen should update itself in, say, every 10 seconds. The user should have the possibly to change some configurations or gwt help by pressing different keys (like you can do when running e.g. 'top'). In other words: the program should NOT wait for the keypress (so input() is not the solution), but simply capture keypresses and act accordingly. If no key is pressed, the program should continue updating the screen. Practically I am looking for something similar than Pascal's "keypressed" function (http://www.freepascal.org/docs-html/rtl/crt/keypressed.html). The python code would be something like this: --- snip --- while True: if keypressed: ch=screen.getch() # From 'curses' # Test, if 'ch' is a valid key # Do what the user want read_sensors() update_screen() --- snip --- I have searched in the Web and in several tutorials (e.g. "Programming python"), but this seems to be a tricky one. The 'pyHook' library seems to offer a keyboard hook manager, but 'pyHook' is not available for linux :( IMHO, the 'curses' library offers no (direct) solution to this... Does anybody have an idea / a solution, how to capture keystrokes in linux? Kind regards, Kimmo -- http://mail.python.org/mailman/listinfo/python-list
Re: Keyboard hook in linux
Hi! Thanks, Michael, for your quick - and heplful - reply. 13.01.2013 18:46, Michael Torrie wrote: You're wrong. curses does offer a direct solution to this. Check the docs. Also here's a nice intro document for Python 3: http://docs.python.org/dev/howto/curses.html You are right :) The docs tell us (I somehow missed this when reading the doc last time): "It’s possible to change this behavior with the method nodelay(). After nodelay(1), getch() for the window becomes non-blocking and returns curses.ERR (a value of -1) when no input is ready. There’s also a halfdelay() function, which can be used to (in effect) set a timer on each getch(); if no input becomes available within a specified delay (measured in tenths of a second), curses raises an exception." This is actually funny: if you google for e.g. "capture keystrokes python", you will find masses of suggestions, none of them having this simple and elegant (i.e. python-like :) ) solution included. Now it works and my problem is solved. Thank you! Kind regards, Kimmo -- http://mail.python.org/mailman/listinfo/python-list
PPC Form Filling Jobs
http://internetjobs4u.weebly.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Deviding N(1,2,3,..,N) part from numeric list as summation of each values(don't sorted) has highest as possible.
Hi! Could it be, "Nuen9", that you would like to find a split where the split sums are close to each other? In other words, you define the number of splits (in your example: 3) and the algortihm should test all possible combinations and select the split where the sum differences are smallest. Best, Kimmo 10.10.2016, 18:20, Nuen9 wrote: เมื่อ วันจันทร์ที่ 10 ตุลาคม ค.ศ. 2016 21 นาฬิกา 31 นาที 25 วินาที UTC+7, Steve D'Aprano เขียนว่า: On Tue, 11 Oct 2016 12:38 am, amornsak@gmail.com wrote: I'm sorry for my English language. OK, I have list = [10,20,30,40,110,50,18,32,5] and want to find three values of summation from my list by split any way list but three values of summation has closely example. [10,20,30], [40,110,50], [18,32,5] = 60, 200, 55 -> it is not closely *** 60 = 10+20+30, 200 = 40+110+50, 18+32+5 = 55 and [10], [20,30,40,110,50,18], [32,5] = 10, 268, 37 -> and it is not closely and [10,20,30,40],[110],[50,18,32,5] = 100,110,105 -> it's closely The Really answers that I want is [10,20,30,40],[110],[50,18,32,5] = 100,110,105 from list[10,20,30,40,110,50,18,32,5] And I don't know what I have to explain for my questions in English because My English so bad T_T Thank you for reading my text (; -- https://mail.python.org/mailman/listinfo/python-list
Re: Deviding N(1,2,3,..,N) part from numeric list as summation of each values(don't sorted) has highest as possible.
Hi! Here one possible solution: --- snip --- land = [10,20,30,40,110,50,18,32,5] landlength=len(land) winnersplit=[] for i in range(landlength-2): for j in range(landlength-1-i): splitsums=[sum(land[0:(i+1)]), sum(land[(i+1):(i+j+2)]), sum(land[(i+j+2):landlength])] differences=abs(splitsums[1]-splitsums[0])+abs(splitsums[2]-splitsums[1]) if (len(winnersplit)==0 or differences<(abs(sum(winnersplit[1])-sum(winnersplit[0]))+abs(sum(winnersplit[2])-sum(winnersplit[1]: winnersplit=[land[0:(i+1)], land[(i+1):(i+j+2)], land[(i+j+2):landlength]] print(splitsums," <<< WE HAVE A NEW LEADER! >>>") else: print(splitsums, " <<< split differences too large :( >>>") print("And the winner is ... ", winnersplit) --- snip --- HTH, Kimmo 10.10.2016, 19:25, Nuen9 kirjoitti: Hi! Could it be, "Nuen9", that you would like to find a split where the split sums are close to each other? In other words, you define the number of splits (in your example: 3) and the algortihm should test all possible combinations and select the split where the sum differences are smallest. Best, Kimmo Yes it is, I want example python code for finding my answers but I don't code my answers. please help me. -- https://mail.python.org/mailman/listinfo/python-list
Help me!, I would like to find split where the split sums are close to each other?
Help me!, I would like to find split where the split sums are close to each other? I have a list is test = [10,20,30,40,50,60,70,80,90,100] and I would like to find split where the split sums are close to each other by number of splits = 3 that all possible combinations and select the split where the sum differences are smallest. Please example code or simple code Python. Thank you very much K.ademarus -- https://mail.python.org/mailman/listinfo/python-list
installing modules problem
Hello, My name is Ian Kilty and I have been having trouble with pip. I have pip installed, and I have tried to install modules they say they are installed in cmd, but when I go into python and import the module, it can't find it. I hope there is a simple solution to this problem, please let me know as soon as possible. -- from Not A User because I don't want to be made fun of in Tron -- -- https://mail.python.org/mailman/listinfo/python-list
Subject: Python Open-Source Snippets Newsletter
Hi, I am creating a Python newsletter showcasing useful code snippets from popular open-source libraries. I will also be providing a runnable demo link to better understand the working. Newsletter subscription link: https://www.pythonninja.xyz/subscribe A sample snippet from the newsletter: HTTP Request retrying with Backoffs - Technique for retrying failed HTTP requests. From Google Maps Services Python (https://github.com/googlemaps/google-maps-services-python) Demo link: https://repl.it/@PythonNinja/requestretries """ first_request_time: The time of the first request (None if no retries have occurred). retry_counter: The count of retries, or zero for the first attempt. """ if not first_request_time: first_request_time = datetime.now() elapsed = datetime.now() - first_request_time if elapsed > self.retry_timeout: raise googlemaps.exceptions.Timeout() if retry_counter > 0: # 0.5 * (1.5 ^ i) is an increased sleep time of 1.5x per iteration, # starting at 0.5s when retry_counter=0. The first retry will occur # at 1, so subtract that first. delay_seconds = 0.5 * 1.5 ** (retry_counter - 1) # Jitter this value by 50% and pause. time.sleep(delay_seconds * (random.random() + 0.5)) Subscribe here: https://www.pythonninja.xyz/subscribe Feedbacks and criticism are welcome. -- https://mail.python.org/mailman/listinfo/python-list
problem in installation of python 3.9.0
Hello, I am Priyankgasree, i am facing problem in installing python3.9.0. after i finish download it always says you have to repair or uninstall. I have repaired and uninstalled and reinstalled several times but i can't do anything . And also I cant able to download other versions of python. So tell me what`s the problem and the solution -- https://mail.python.org/mailman/listinfo/python-list
How to copy the entire outlook message content in python
Hello All, I'm a beginner trying to achieve the below in my python script: Can anyone help me on this? I'm stuck at step2. 1. Input: A locally saved outlook mail (*.msg) path 2. Go to the path and Copy the entire body of the mail 3. Create a new mail and paste the contents into new mail 4. send it manually # # === Script Start == # import win32com.client as win32 ### Functions def getMailBody(msgFile): start_text = "" end_text = "" with open(msgFile) as f: data=f.read() return data[data.find(start_text):data.find(end_text)+len(end_text)] def releaseMail(body, subject, recipient): outlook = win32.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = recipient mail.Subject = subject mail.HtmlBody = body mail.Display(True) ### Main msgFile = "C:\\RELM\\testMsg.msg" mailTo = "mym...@myserver.com" mailSubject = "Test message" mailBody = getMailBody(msgFile) releaseMail(mailBody, mailSubject, mailRecipient) # # Script End === # Below is the error I'm getting. == File "C:\Python\Python38-32\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 924: character maps to -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with chaos math extensions.
In case you missed it, I said I have windows XP. Windows XP pre-compiled python binaries are built on VS .NET 2003. In order to build extensions, you need the compiler the interpreter was built on, or at least that is what is reported to me by calling setup.py. If I was using linux, which I currently am not, it'd be a different story. Additionally, GCC isn't available for windows XP, only MinGW, the port, and I don't know that much about it to use it running on a Windows platform. Furthermore, I was asking for help on an extension, not an economical question about my programming environment. Thanks > > > On Oct 4, 2005, at 10:25 PM, Brandon Keown wrote: >> >>I have programmed a fractal generator (Julia Set/Mandelbrot Set) >> in python in the past, and have had good success, but it would run so >> slowly because of the overhead involved with the calculation. I >> recently purchased VS .NET 2003 (Win XP, precomp binary of python >> 2.4.2rc1) to make my own extensions. > > Why did you need to purchase anything when gcc is available for free? > > > --- > Andrew Gwozdziewycz > [EMAIL PROTECTED] > http://ihadagreatview.org > http://plasticandroid.org > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with chaos math extensions.
Here's the Script it was being used in (forgive it if it seems a bit messy, i have been tinkering with variables and such to try different ideas and haven't really cleaned it up). import ctest import Tkinter import threading hue_map = ("#FF","#FEFEFF","#FDFDFF","#FCFCFF","#FBFBFF","#FAFAFF","#F9F9FF","#F8F8F8","#F7F7FF","#F6F6F6","#FF","#FF","#FF","#FF","#FF","#FF","#FF",\ "#FF","#FF","#FF","#FF","#FF","#FF","#FF","#FF") class Mandelbrot_Set(Tkinter.Canvas): def __init__(self,master,iters): Tkinter.Canvas.__init__(self,master) self.dims = {'x':500,'y':500} self.config(height=self.dims['y'],width=self.dims['x']) self.r_range = (-2.0,2.0) self.i_range = (-2.0,2.0) self.iters = iters self.prec = {'r':1.*(self.r_range[1]-self.r_range[0])/(self.dims['x']),'i':1.*(self.i_range[1]-self.i_range[0])/self.dims['y']} self.escapemap = ctest.escapeMap(-1j,self.iters,(self.dims['x'],self.dims['y']),(self.r_range[0],self.r_range[1]),(self.i_range[0],self.i_range[1])) self.select = False self.select_event = (0,0) self.sbox = None self.bind("",self.selection_box) self.bind("",self.select_update) self.t_draw = threading.Thread(target=self.draw) self.t_draw.start() def draw(self): for j in range(self.dims['y']): i = 0 while i < self.dims['x']: cur = 0; try: color = self.escapemap[j][i] while self.escapemap[j][i+cur] == color: cur+=1 except IndexError: break; hue_step = 1.*len(hue_map)/self.iters if color == -1: f = "#00" else: f = hue_map[int(hue_step*color)] self.create_line(i,j,i+cur,j,fill=f) i+=cur def selection_box(self,event): if not self.select: self.select_event = (event.x,event.y) self.select = True else: self.r_range = self.new_range(event.x,self.select_event[0]) self.i_range = self.new_range(event.y,self.select_event[1]) print self.r_range,self.i_range self.select = False self.delete(Tkinter.ALL) self.t_draw.run() self.select_update(event) def new_range(self,x,y): if x > y: return (y,x) else: return (x,y) def select_update(self,event): if not self.select: return else: if self.sbox != None: self.delete(self.sbox) self.sbox = self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#00") else: self.sbox = self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#00") if __name__ == "__main__": root = Tkinter.Tk() c = Mandelbrot_Set(root,50) c.pack() root.mainloop() The error occurs in the instantiation of the Mandelbrot_Set object. Additionally in little mini timing scripts such as import time import ctest t = time.time() c = ctest.escapeMap(-1j,100,(500,500)) print time.time()-t this will crash it too however I found that just opening up the interpreter and typing import ctest ctest.escapeMap(-1j,100,(50,50)) #50 yields much smaller output than 500x500 it generates a 2d tuple fine. So the error seems really obscure to me, and I don't understand it. Brandon Keown wrote: I have programmed a fractal generator (Julia Set/Mandelbrot Set) in python in the past, and have had good success, but it would run so slowly because of the overhead involved with the calculation. I recently purchased VS .NET 2003 (Win XP, precomp binary of python 2.4.2rc1) to make my own extensions. I was wondering if anyone could help me figure out why I'm getting obscure memory exceptions (runtime errors resulting in automatic closing of Python) with my extension. It seems to run okay if imported alone, but when accompanied in a list of instructions such as a function it crashes. a short script or interpreter session that illustrates how to get the errors would help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Extending Python
I own Python in a Nutshell, as one person pointed out. Alex Martelli does a great job of introducing the concepts, as long as your'e familiar with C. Additionally he covers wrapping (which is sounds like you're trying to do) with SWIG, Pyrex, and a few other options. It's a great book, I have used no other (save python docs) after my introduction. > I am looking for a good tutorial on how to extend python with C code. I > have an application built in C that I need to be able to use in Python. > I have searched through various sources, starting of course with the > Python site itself, and others, but I felt a bit lacking from the > Python site, it seems it was only made for those who installed the > source distribution, as for the other people... Anyways, thanks for the > help! > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with chaos math extensions.
Well, I didn't buy it JUST to compile python extensions, I'm looking to write C++ apps as well, I just use python for a lot of math and science simulations, and I got VS .NET at heavy discount since I'm a student. > Brandon K wrote: >> In case you missed it, I said I have windows XP. Windows XP >> pre-compiled python binaries are built on VS .NET 2003. In order to >> build extensions, you need the compiler the interpreter was built on, >> or at least that is what is reported to me by calling setup.py. If I >> was using linux, which I currently am not, it'd be a different story. >> Additionally, GCC isn't available for windows XP, only MinGW, the >> port, and I don't know that much about it to use it running on a >> Windows platform. Furthermore, I was asking for help on an extension, >> not an economical question about my programming environment. >> >> Thanks >> >>> >>> On Oct 4, 2005, at 10:25 PM, Brandon Keown wrote: >>> >>>> I have programmed a fractal generator (Julia Set/Mandelbrot Set) >>>> in python in the past, and have had good success, but it would run >>>> so slowly because of the overhead involved with the calculation. I >>>> recently purchased VS .NET 2003 (Win XP, precomp binary of python >>>> 2.4.2rc1) to make my own extensions. >>> >>> Why did you need to purchase anything when gcc is available for free? >>> > Since gcc isn't an option, the logical way to proceed would be to do > what others have done and install the Microsoft Toolkit compiler, > available from their web site for the outrageous price of nothing. I can > vouch that it really does compile extensions for Python 2.4 on Windows, > having done that myself. > > See > > http://www.vrplumber.com/programming/mstoolkit/ > > regards > Steve == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: Absolultely confused...
> If I take out the "!" in the format string and just use "O", I can at > least get past PyArg_ParseTuple. Is this a compile-time error? Or a runtime error? == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: recursive function
Is there no way to implement your idea in a classical loop? Usually the syntax is cleaner, and there is no limit (except the limit of the range function in certain cases). For example what would be wrong with. def foo(j): while j < n: j+=1 return j I don't know much about the internals of python, but to me it seems like if you're going to be doing this on the level of 1000s of iterations, there might be some overhead to using recursion (i.e. function calls) that a loop wouldn't have (but that's just a guess). > Hello, > > In a recursive function like the following : > > > def foo( j ) : > j += 1 > while j < n : j = foo( j ) > return j > > > in found that the recursivity is limited (1000 iterations). Then, I have > two questions : > - why this mecanism has been implemented ? > - it is possible to increase or remove (and how) the number of iterations ? > > Regards, > Mathieu == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: recursive function
> def foo(j): > while j < n: > j+=1 > return j > of course I mean: def foo(j): while j < n: j+=1 return j sorry == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: new forum -- homework help/chit chat/easy communication
Hrm...i find it demeaning to relegate Python to a scripting language while Visual Basic is in the "software development" section. Python so outdoes VB in every way shape and form. > I've launched a new forum not too long ago, and I invite you all to go > there: www.wizardsolutionsusa.com (click on the forum link). We offer > all kinds of help, and for those of you who just like to talk, there's > a chit chat section just for you...Just remember that forum > communication is much easier, safer, and faster. > == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: new forum -- homework help/chit chat/easy communication
[EMAIL PROTECTED] wrote: > I've launched a new forum not too long ago, and I invite you all to go > there: www.wizardsolutionsusa.com (click on the forum link). We offer > all kinds of help, and for those of you who just like to talk, there's > a chit chat section just for you...Just remember that forum > communication is much easier, safer, and faster. > [.section Blurb] About me: My name is James (Cantley) Sheppard. I am a North Carolina resident, at the age of 16. I have been programming since the age of 12, and enjoy it as lifes[sic] greatest passion. In the future, I would love to become the leading Software Engineer at a fairly large company, and maybe someday own my own business. As of right now, I am currently in high school and planning on going to a four year college somewhere around the country. Well, that is my life story, and about all I got to say! [.section Commentary] Hrm, obviously hasn't had enough programming experience in 4 years to quite know what he's talking about. Before making random "assertions" James, you might want to take into account the community you're talking to. I don't know about you guys, but I've had enough teen start up webpages. They clog the web. No offense of course to the younger readers, its just...it's like E/N sites...junk most of the time. == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: new forum -- homework help/chit chat/easy communication
> In other words, what is the difference between a "scripting language" > and a "programming language". > Good point. == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows installer, different versions of Python on Windows
When you install Python it plug entries into the registry, so that when you go to install add-ons that are pre-compiled binaries, they look into the registry for the python directory. If you can find out how to manipulate the registry so that the binaries would recognize different installations, you'd be good to go. This would probably involve having copies of the same key with different values. > I would like to install several copies of Python 2.4.2 on my machine, > but it doesn't seem to be possible. > > If I allready has a version installed, the installer only gives the > options to: > > - change python 2.4.2 > - repair python 2.4.2 > - remove python 2.4.2 > > I would like to install different versions of Zope 3, and since it is > installed under a specific python version, the simplest solution would > be to install several Python versions, and install a different zope3 > version under each python install. > > Have I misunderstood something here? > > == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Confused on Kid
Hey, so I heard about the TurboGears posting and decided to investigate. I watched some of their video on building a wiki in 20 minutes and was totally blown away because I'm used to python...straight python, not melding together 4 different APIs into one to blah blah. ANYWAY. I was investigating each subproject individually and could not, for the life of me figure out how Kid worked. I understand that it takes a well-formed XML document and transforms it, but I could not figure out where it transforms it, or how to transform a document. They have plenty of template examples, but I'm left say, "What do I do with this?" I know I can't just pop in it a browser because it has no sort of style sheet or anything so it would just render as an XML document. What do you do after you have a kid template? == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: C Extension - return an array of longs or pointer?
All the veteran programmers out there can correct me, but the way I did it in my extension was this: static PyObject *wrap_doNumberStuff(PyObject* self, PyObject* args) { char* in = 0; char* x = 0; long* result = 0; int i = 0; PyObject* py = PyTuple_New() int ok = PyArg_ParseTuple(args,"ss",&in, &x); if(!ok) return NULL; result = doNumberStuff(in,x): len = sizeof(result)/sizeof(long) for(i;i < len; i++) PyTuple_SET_ITEM(py, i,Py_BuildValue("l",*result[i]) } Simple enough idea...i'm not quite sure if I've done everything correctly with the pointers, but I'm sure you can figure that out, the algorithm is simple enough. > Hi, >I have been posting about writing a C extension for Python...so far, > so good. At least for the "simple" functions that I need to wrap. > > Ok, my c function looks like... > > MY_NUM *doNumberStuff(const char *in, const char *x) { ... } > > MY_NUM is defined as, typedef unsigned long MY_NUM; (not sure if that > matters, or can i just create a wrapper which handles longs?) > > anyhow..for my wrapper I have this.. > > static PyObject *wrap_doNumberStuff(PyObject *self, PyObject args) { > char *in = 0; > char *x = 0; > long *result = 0; > int ok = PyArg_ParseTuple(args, "ss", &in, &x); > if (!ok) return 0; > > result = doNumberStuff(in, x); > > return Py_BuildValue("l", result); > } > > ...my question is...in the c code, result is a pointer to an array of > longs, how can I get the returned result to be a list or something > similar to an array in Python? > > ...I also have a function which returns a character array (denoted by a > char *)...would it work the same as the previous question? > > Thanks!! > == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: C Extension - return an array of longs or pointer?
I'm sorry...I just woke up and forgot my C...must have left it in the Coffee...Anyway, i made a few mistakes (can't initialize blank tuple...function should return a value, lol). static PyObject* wrap_doNumberStuff(PyObject* self, PyObject* args) { char* in = 0; char* x = 0; long* result = 0; int i = 0; PyObject* py = NULL; if(!PyArg_ParseTuple(args,"ss",&in,&x) return NULL; result = doNumberStuff(in,x); len = sizeof(result)/sizeof(long); py = PyTuple_New(len); for(i; i < len; i++) PyTuple_SET_ITEM(py, i, Py_BuildValue("l",*result[i]); return py; } Additionally, the Python/C api in the docs tells you all of these nifty little abstract layer functions that you can call from your extension. > All the veteran programmers out there can correct me, but the way I did > it in my extension was this: > > static PyObject *wrap_doNumberStuff(PyObject* self, PyObject* args) > { > char* in = 0; > char* x = 0; > long* result = 0; > int i = 0; > PyObject* py = PyTuple_New() > int ok = PyArg_ParseTuple(args,"ss",&in, &x); > if(!ok) return NULL; > > result = doNumberStuff(in,x): > len = sizeof(result)/sizeof(long) > for(i;i < len; i++) > PyTuple_SET_ITEM(py, i,Py_BuildValue("l",*result[i]) > } > > Simple enough idea...i'm not quite sure if I've done everything > correctly with the pointers, but I'm sure you can figure that out, the > algorithm is simple enough. > == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: coloring a complex number
I'm not 100% sure about this, but from what it seems like, the reason method B worked, and not method a is because class foo(complex) is subclassing a metaclass. So if you do this, you can't init a meta class (try type(complex), it equals 'type' not 'complex'. type(complex()) yields 'complex'), so you use the new operator to generator a class on the fly which is why it works in method B. I hope that's right. -Brandon > Spending the morning avoiding responsibilities, and seeing what it would > take to color some complex numbers. > > class color_complex(complex): > def __init__(self,*args,**kws): > complex.__init__(*args) > self.color=kws.get('color', 'BLUE') > a=color_complex(1,7) print a > (1+7j) #good so far a=color_complex(1,7,color='BLUE') > Traceback (most recent call last): > File "", line 1, in -toplevel- >a=color_complex(1,7,color='BLUE') > TypeError: 'color' is an invalid keyword argument for this function > > No good... it seems that I am actually subclassing the built_in function > 'complex' when I am hoping to have been subclassing the built_in numeric > type - complex. > > but some googling sends me to lib/test/test_descr.py > > where there a working subclass of complex more in > accordance with my intentions. > > class color_complex(complex): >def __new__(cls,*args,**kws): >result = complex.__new__(cls, *args) >result.color = kws.get('color', 'BLUE') >return result > a=color_complex(1,7,color='BLUE') print a > (1+7j) print a.color > BLUE > > which is very good. > > But on the chance that I end up pursuing this road, it would be good if > I understood what I just did. It would certainly help with my > documentation ;) > > Assistance appreciated. > > NOTE: > > The importance of the asset of the depth and breadth of Python archives > - for learning (and teaching) and real world production - should not be > underestimated, IMO. I could be confident if there was an answer to > getting the functionality I was looking for as above, it would be found > easily enough by a google search. It is only with the major > technologies that one can hope to pose a question of almost any kind to > google and get the kind of relevant hits one gets when doing a Python > related search. Python is certainly a major technology, in that > respect. As these archives serve as an extension to the documentation, > the body of Python documentation is beyond any normal expectation. > > True, this asset is generally better for answers than explanations. > > I got the answer I needed. Pursuing here some explanation of that answer. > > Art > > == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: the Journey of Foreign Characters thru Internet
So just stop talking. It's funny that you guys are having a conversations about not responding to a guys post. First of all, freedom of speech, blah blah, who cares, just let him alone. But certainly don't go on his post, reply, telling people not to reply. That's like saying EVEN THOUGH I'M doing this, YOU should not do it. JUST STOP ALREADY :-). There is of course, the option...instead of starving the troll...FEED HIM TILL HE BURSTS! == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way of storing 1024*1024 bits
BTW, it'd be 6 megabits or 750kb ;) > Six megabytes is pretty much nothing on a modern computer. == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: computer programming
what is .tk? Turkmenistan? or is it just some arbitrary suffix. > www.javaholics.tk == Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups == Get Anonymous, Uncensored, Access to West and East Coast Server Farms! == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM == -- http://mail.python.org/mailman/listinfo/python-list
Re: Counting processors
You can use print os.sysconf("SC_NPROCESSORS_CONF") works on Linux krishan Pauldoo wrote: > Hi, > Is a way in python to obtain the total number of processors present in > the system? > > os.platform doesn't seem to contain anything useful. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 18, Issue 349
Regards, KSrinivasan Disclaimer: This e-mail is bound by the terms and conditions described at http://www.subexsystems.com/mail-disclaimer.htm - Original Message - From: <[EMAIL PROTECTED]> To: Sent: Tuesday, March 22, 2005 7:11 PM Subject: Python-list Digest, Vol 18, Issue 349 > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > Today's Topics: > >1. Re: Getting the word to conventional programmers (Peter Maas) >2. Re: Getting the word to conventional programmers (Jeff Schwab) >3. Re: Python becoming less Lisp-like (Steve Holden) >4. Re: xmlrpc with Python and large datases (Steve Holden) >5. Re: Anonymus functions revisited (Antoon Pardon) >6. Re: (noob alert) why doesn't this work? (Bouke Woudstra) >7. Re: Pre-PEP: Dictionary accumulator methods (Steve Holden) >8. Re: xmlrpc with Python and large datases (Fredrik Lundh) >9. Doubt regarding exec function (Mosas) > 10. Re: Please help for Python programming (M.E.Farmer) > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Need help vectorizing code
I have some code that I need help vectorizing. I want to convert the following to vector form, how can I? I want to get rid of the inner loop - apparently, it's possible to do so. X is an NxD matrix. y is a 1xD vector. def foo(X, y, mylambda, N, D, epsilon): ... for j in xrange(D): aj = 0 cj = 0 for i in xrange(N): aj += 2 * (X[i,j] ** 2) cj += 2 * (X[i,j] * (y[i] - w.transpose()*X[i].transpose() + w[j]*X[i,j])) ... If I call numpy.vectorize() on the function, it throws an error at runtime. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help vectorizing code
I didn't paste the whole function, note the ... before and after. I do use the values. I want to get rid of one of the loops so that the computation becomes O(D). Assume vectors a and c should get populated during the compute, each being 1xD. Thanks On Saturday, January 18, 2014 12:51:25 PM UTC-8, Kevin K wrote: > I have some code that I need help vectorizing. > > I want to convert the following to vector form, how can I? I want to get rid > of the inner loop - apparently, it's possible to do so. > > X is an NxD matrix. y is a 1xD vector. > > > > def foo(X, y, mylambda, N, D, epsilon): > > ... > > for j in xrange(D): > > aj = 0 > > cj = 0 > > for i in xrange(N): > > aj += 2 * (X[i,j] ** 2) > > cj += 2 * (X[i,j] * (y[i] - w.transpose()*X[i].transpose() + > w[j]*X[i,j])) > > > > ... > > > > If I call numpy.vectorize() on the function, it throws an error at runtime. > > > > Thanks -- https://mail.python.org/mailman/listinfo/python-list
SSL certification fails / tweepy
Dear list members! I have written I small python script for twitter mining utilising the 'tweepy' library. Since a couple of days I cannot use the script anymore, due to a "ssl certificate verification failed" error. The authentication with Twitter API succeess, but when I try to run the following code: --- snip --- api=tweepy.API(auth) # 'auth' is my authentification token print("Receiving network members for '", user_to_track, "' ... ") network_members = [] # # The user wants to get all followers of a twitter user # while True: try: for page in tweepy.Cursor(api.followers_ids, user_to_track).pages(): network_members.extend(page) print("Current follower count: ", len(network_members)) if len(page)==5000: time.sleep(60) break except tweepy.TweepError as e: # Did we exceed the rate limit? if e.message[0]["code"]==88: # Yes -> sleep for 15 minutes and then continue print("Rate limit exceeded, sleeping for 15 minutes ...") time.sleep(15*60) continue else: # Something else went wrong -> break out from the loop! print("Exception: ", e.message[0], " (", e.code[0], ") --> interrupting, sorry!") break --- snip --- the execution is broken with an "ŚSL_VERIFICATION_FAILED" error. I have tried both python 2.7 and 3.x, no difference :( I have also upgraded 'tweepy', no help. I suspect this being somehow related to my current system, i.e. openSuSE Tumbleweed. I tested the script on a ubuntu system and encountered no problems... But I need to get the script running also with my openSuSE :) Any ideas what could be causing this weird problem? Thanks in advance! Kimmo -- https://mail.python.org/mailman/listinfo/python-list
Re: SSL certification fails / tweepy [SOLVED]
Hi! 14.01.2016, 09:59, dieter wrote: "SSL_VERIFICATION_FAILED" is an error which occurs when an SSL ("https") connection is established. It happens when the SSL certificate (of the server and/or client) does not contain expected data - e.g. the certificate is no longer (or not yet) valid or its subject does not reference the connected entity or the certificate chain cannot be verified. Look for Python documentation on SSL verification to learn how to properly set up things for successful verfication. Among others, you will need have somewhere information about trusted root certificates. Thanks, dieter, for your reply. I have now re-installed both certificate packages and (open)ssl related python packages - and now it works! I still wonder why openSuSE certificates are not working out-of-box with python. Maybe some of the packages were not correctly installed... Anyway, thanks for your quick reply - the issue is now solved :) Best, Kimmo -- https://mail.python.org/mailman/listinfo/python-list
Re: merging two csv files
Hi! Is this a homework or something you need a quick solution for? For the latter: 'man paste' (on Linux) :) Anyway, some sample data and code would be good. BR, Kimmo 03.03.2016, 11:50, m.t.e...@student.rug.nl wrote: Hey! I want to merge column-wise two csv files, say: file1.csv and file2.csv, both containing two columns, into a new csv file. I could not find a good code for doing this. It never really worked. If you could show me the code with this example, I would highly appreciate it. Best wishes, Tiber -- https://mail.python.org/mailman/listinfo/python-list
Re: Topic Modeling LDA Gensim
Hi, I don't know how to contact you by email, nor am I going to answer your question. I have a question for you. Please help if you can. On running the code from this page ( Unsupervised Learning ): http://nbviewer.ipython.org/gist/rjweiss/7158866# The output of 'lda[corpus[1]]' keeps changing each time. Why is it so ? Please help! Waiting for your reply, Sreenath K -- https://mail.python.org/mailman/listinfo/python-list
Integration using scipy odeint
Dear all I'm using Python 3.4.3. I am facing a problem in integrating using odeint solver. In the following code, tran is a function and in those are the variables which are arrays. These variables change their values with respect to time (the time which I pass to the function). I tried defining a loop inside the function, but Python throws an error saying float object not iterable. Please guide me how to solve this problem. #initial is an array containing initial values for the integration, dt is the time array with unequal time steps, which I have captured from other part of the code def tran(initial,dt): for i in dt: k1 [i] = 2.8e8 * math.exp(-21100/ta[i]) # k1,k2,k3 & k4 are constants which change according to temperature (ta), which in turn changes with respect to time. k2 [i] = 1.4e2 * math.exp(-12100/ta[i]) # ta changes its values according to dt, which is array. It runs from 0-6 with unequal time steps. k3 [i] = 1.4e5 * ta[i] * math.exp(-19680/ta[i]) # I've captured dt and all other arrays here from another loop, which is not of importtance. k4 [i] = 1.484e3 * ta[i] y = initial[0] z = initial[1] dn = (6*rho*initial[1]) dd = (math.pi*2000*initial[0]) ds = (dn/dd)**1/3 dydt = (166.2072*ta[i]*cca[i] - (1.447e13 * ta[i]**0.5 * rho**1/6 * y**1/6 * rho**1/6 * z**1/6 * 0.0832)) # cca,ta are arrays. y & z are 2 dependent variables dzdt = (k1[i]*ta[i]*cca[i]*12.011 + (21.2834*k2[i]*ta[i]*cca[i] * y**1/2 *ds) - (k3[i]*ta[i]*12.011*y*math.pi*ds**2 * cco[i]) - (phi*k4[i]*ta[i]*xo[i]*12.011*y*math.pi*ds**2)) return [dydt,dzdt] # dydt & dzdt are my final time integrated values initial = [0.01,1e-5] sol = odeint(tran, initial, dt) #this is my function call If I pass array in my function call, it says only length-1 can be converted to Python scalars. So I request all the experts in the group to tell me where I'm going wrong. Regards -- https://mail.python.org/mailman/listinfo/python-list
help regarding extracting a smaller list from larger one
Dear Python Users, I am trying to write a code for visualization (raster plots and peri-event time histogram) of time series electrophysiological data using numpy, scipy and matlplotlib in python. I am importing the data into list using loadtext command. I was curious if anyone is aware of a function in numpy that can *extract a smaller list containing numbers from a larger list* given the upper and lower limit of the values between which the smaller list lies. Thank you in advance. Sincerely, niranjan -- Niranjan Kambi Senior Research Fellow, Neeraj Lab, National Brain Research Centre, Manesar, Gurgaon-122050 Haryana, INDIA Ph:+919818654846 website:- http://www.nbrc.ac.in/faculty/neeraj/Lab_webpage/Niranjan_Kambi.html email:- neuro.n...@nbrc.res.in, neuron...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: help regarding extracting a smaller list from larger one
Dear Gary, thank you for the reply. I will be more specific and take the same example that you have given and tell you what is my problem - array([0.0, 1.3, 2.45, 3.87, 4.54, 5.11, 6.90, 7.78, 8.23, 9.01]) from this array I want to a sub-list with lower and upper indexes that are not present in the above array for example - sub-list[3, 8] Is there a function for this? thank you niranjan On Thu, Sep 15, 2011 at 10:54 PM, Gary Herron wrote: > On 09/15/2011 09:40 AM, neeru K wrote: > >> Dear Python Users, >> I am trying to write a code for visualization (raster plots and peri-event >> time histogram) of time series electrophysiological data using numpy, scipy >> and matlplotlib in python. I am importing the data into list using loadtext >> command. >> I was curious if anyone is aware of a function in numpy that can *extract >> a smaller list containing numbers from a larger list* given the upper and >> lower limit of the values between which the smaller list lies. >> Thank you in advance. >> Sincerely, >> niranjan >> >> -- >> Niranjan Kambi >> Senior Research Fellow, >> Neeraj Lab, >> National Brain Research Centre, >> Manesar, Gurgaon-122050 >> Haryana, INDIA >> Ph:+919818654846 >> website:- http://www.nbrc.ac.in/faculty/**neeraj/Lab_webpage/Niranjan_** >> Kambi.html<http://www.nbrc.ac.in/faculty/neeraj/Lab_webpage/Niranjan_Kambi.html> >> email:- neuro.n...@nbrc.res.in <mailto:neuro.n...@nbrc.res.in**>, >> neuron...@gmail.com <mailto:neuron...@gmail.com> >> >> Do mean to extract a sub-list from a list based on lower and upper > indexes into the list? Python has a standard notation for indicating > sub-lists, and numpy implements them: > > >>> a = numpy.array(range(10)) > >>> a > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > >>> a[3:6] > array([3, 4, 5]) > > If you mean something else, please be more specific, and we'll try again. > > Gary Herron > > > -- > Gary Herron, PhD. > Department of Computer Science > DigiPen Institute of Technology > (425) 895-4418 > > -- > http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> > -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/
Online Data Entry Jobs Without Investment http://ponlinejobs.yolasite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: nested loops
Hi! > leonardo writes: how can i have it print a row of stars beside each number, like this?: how many seconds?: 5 5 * * * * * 4 * * * * 3 * * * 2 * * 1 * blast off! --- snip --- sec = int(input("How many seconds? ")) for i in range(0,sec): print str(sec-i)+":"+" *"*(sec-i) print "blast off!" --- snip --- Please note: the value for the upper bound is not included in the range. In my example, the actual range is from 0 to 4. HTH, Kimmo -- http://mail.python.org/mailman/listinfo/python-list
Python module vs library
Hi, what is the difference between python module and library ? -- http://mail.python.org/mailman/listinfo/python-list
Which is the best GTK
Hi all, I am a new one to python. I want which is the best gtk. Tkinter or Tix or etc., . Please suggest me some documentation. Thanks, Satish. Team Spiderace, www.spiderace.com. Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
What is the UI Element to work with HTML Content
Hi All, I am a newbie to Python. I want to know that there is any UI Control to browse HTML pages. Please let me know. If that is available, I am planing to develop a Chat application. Waiting for help. Thanks, Satish. [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
XML RFC Server
Hi All, Is there any example code to develop XML RFC Web Service in Python. Thanks, Satish.Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Help with dbm TypeError
I am writing a web application for mod_python that catalogs my home (book) library. For now, I am using the Python dbm module to store string representations of mod_python's req.form (using the mod_python.publisher handler) using unique IDs as keys. In the .db file, there is a key 'next' that holds the next key for the next form submission. A TypeError exception is raised though when I attempt to increment the 'next' key. This only occurs in mod_python. This code... self._db['next'] = str(int(self._db['next'])+1) raises this exception TypeError: string indices must be integers >>> y = dbm.open("Test","c") >>> next = 0 >>> y['next'] = str(next) >>> y['next'] = str(int(y['next'])+1) >>> y['next'] '1' >>> y['next'] = str(int(y['next'])+1) >>> y['next'] '2' I do not understand the cause of this exception. I am using Python 2.3.5. Any help would be greatly appreciated. Ryan Kaskel -- http://mail.python.org/mailman/listinfo/python-list
What is the method for class destroy
Hi All, Like __init__ which is called when object instatiated, what is the method when object destroys. Thanks, Satish.Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
how to handle jpg images with Tkinter
Hi, I am not able to load jpg images in photoimage widget. That is showing different different errors. can I find any examples on internet. Thanks, SatishSend instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
numpy slice: create view, not copy
Hi, given an array: import numpy a = numpy.arange(100).reshape((10,10)) print a [[ 0 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18 19] [20 21 22 23 24 25 26 27 28 29] [30 31 32 33 34 35 36 37 38 39] [40 41 42 43 44 45 46 47 48 49] [50 51 52 53 54 55 56 57 58 59] [60 61 62 63 64 65 66 67 68 69] [70 71 72 73 74 75 76 77 78 79] [80 81 82 83 84 85 86 87 88 89] [90 91 92 93 94 95 96 97 98 99]] I'd like to create a new array that is a view of a, i.e. it shares data. If a is updated, this new array should be automatically 'updated'. e.g. the array west should be a view of a that gives the element at the left of location i,j in a. a[i,j] = west[i,j+1] west can be created using: a[:,range(-1,a.shape[1]-1)] As you can see, this also defines periodic boundaries (i.e. west[0,0] = 9) but it seems that this returns a copy of a, not a view. How can I change the slice definition in such a way it returns a view? Thanks in advance, Karel -- http://mail.python.org/mailman/listinfo/python-list
py and Dabo class in chi
I am organizing 3 python events in Chicago: 2 free, one cheap. 1st is really just an extended VFP users group meeting featuring Ed Leafe, one of the Dabo developers. I am getting a larger room to accommodate the python group too. The meeting is Nov 14 5:30pm in the loop: (not sure yet where, watch this page http://chipy.org/EdOnDabo ) There is some interest in an afternoon talk at 1:00 to 4:30. If I can get 5 or so people to commit to showing up, then Ed will talk then too. Probably worth staying for the evening presentation too - the Q/A will be worth as much as his presentation. I am hosting a 2 day mini event too: http://chipy.org/BootCampy - nothing like a fest. For this I am planing on spending a few $ on an instructor, which I have not found yet - I have some nibbles - but hoping to get a few more instead of just going with the first to respond. So if anyone is interested in either attending or instructing, please let me know. And of course, please forward this to any other list/group that may have some interest. If you are interested, or are near Chicago, please join the chipy list: http://mail.python.org/mailman/listinfo/chicago very low post rate - about 5 per day, mostly about the monthly meetings. Carl Karsten -- http://mail.python.org/mailman/listinfo/python-list
ValueError: too many values to unpack
Hi, I am very new to pyton, during my adventures journey I got the following error message which am not able to solve, can somebody help me. I was trying to format my output in a readable way, Compare results in tblItem 71 records found in pctrsqlstage case9125 71 records found in qa-sql2\pctr case9126 Database counts match: True 71 unique records found in pctrsqlstage case9125 71 unique records found in qa-sql2\pctr case9126 56 records were different Type, FileType, Item, Hash, Path, Size, CullCd, Ext, DtCr, DtLMd, DtLAc Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "Q:\PythonScripts\InventoryCompareCase.py", line 234, in ? main() File "Q:\PythonScripts\InventoryCompareCase.py", line 117, in main for (Type,FileType,Item,Hash,Path,Size,CullCd,Ext,DtCr,DtLMd,DtLAc) in infoDiffs : ValueError: too many values to unpack Thanks Retheesh -- http://mail.python.org/mailman/listinfo/python-list
Re: ValueError: too many values to unpack
Thank you, that solved my problem. Thanks Retheesh alisonken1 wrote: > [EMAIL PROTECTED] wrote: > > > 56 records were different > > Type, FileType, > >Item, > > Hash, > > > > Path, Size, CullCd, Ext, DtCr, > > DtLMd, DtLAc > > Traceback (most recent call last): > > File > > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > > line 310, in RunScript > > exec codeObject in __main__.__dict__ > > File "Q:\PythonScripts\InventoryCompareCase.py", line 234, in ? > > main() > > File "Q:\PythonScripts\InventoryCompareCase.py", line 117, in main > > for (Type,FileType,Item,Hash,Path,Size,CullCd,Ext,DtCr,DtLMd,DtLAc) > > in infoDiffs : > > ValueError: too many values to unpack > > > > Thanks > > Retheesh > > The "too many values to unpack" indicates you don't have enough > variables in the [for (...) in infoDiffs: ] construct. > > You also may want to change some of the names; although "Type" > (variable name) and "type" (python function) should be different, it's > good practice to not use names that are similar to functions. -- http://mail.python.org/mailman/listinfo/python-list
TypeError: unsubscriptable object
Can anybody tell me why am I getting this error message while trying to print a part of a string. Is there a better approach for this... Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "Q:\PythonScripts\InventoryCompareCase.py", line 276, in ? main() File "Q:\PythonScripts\InventoryCompareCase.py", line 167, in main print template % (ID, IID, Function[:10], Description[:10], ErrorNumber, StatusCD) TypeError: unsubscriptable object Thanks Retheesh -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: unsubscriptable object
So wat should I do ?? K.S.Sreeram wrote: > [EMAIL PROTECTED] wrote: > > print template % (ID, IID, Function[:10], Description[:10], > > ErrorNumber, StatusCD) > > TypeError: unsubscriptable object > > It means either 'Function' or 'Description' is not a sequence. > Try inserting print statements to see what values they are. > > e.g: > > a = 2 > a[:10] > > will give me an 'unsubscriptable object' > > Regards > Sreeram > > > --enig08E562E3E8ED90BF5BC3C92B > Content-Type: application/pgp-signature > Content-Transfer-Encoding: base64 > Content-Disposition: inline; > filename="signature.asc" > Content-Description: OpenPGP digital signature > X-Google-AttachSize: 253 -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: unsubscriptable object
So wat should I do ?? K.S.Sreeram wrote: > [EMAIL PROTECTED] wrote: > > print template % (ID, IID, Function[:10], Description[:10], > > ErrorNumber, StatusCD) > > TypeError: unsubscriptable object > > It means either 'Function' or 'Description' is not a sequence. > Try inserting print statements to see what values they are. > > e.g: > > a = 2 > a[:10] > > will give me an 'unsubscriptable object' > > Regards > Sreeram > > > --enig08E562E3E8ED90BF5BC3C92B > Content-Type: application/pgp-signature > Content-Transfer-Encoding: base64 > Content-Disposition: inline; > filename="signature.asc" > Content-Description: OpenPGP digital signature > X-Google-AttachSize: 253 -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: unsubscriptable object
So wat should I do ?? K.S.Sreeram wrote: > [EMAIL PROTECTED] wrote: > > print template % (ID, IID, Function[:10], Description[:10], > > ErrorNumber, StatusCD) > > TypeError: unsubscriptable object > > It means either 'Function' or 'Description' is not a sequence. > Try inserting print statements to see what values they are. > > e.g: > > a = 2 > a[:10] > > will give me an 'unsubscriptable object' > > Regards > Sreeram > > > --enig08E562E3E8ED90BF5BC3C92B > Content-Type: application/pgp-signature > Content-Transfer-Encoding: base64 > Content-Disposition: inline; > filename="signature.asc" > Content-Description: OpenPGP digital signature > X-Google-AttachSize: 253 -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: unsubscriptable object
I did the same, The function type is < NoneType> and the description type is so how can i print a part of this 2 output. These values are returned by database. Thanks Retheesh Laszlo Nagy wrote: > [EMAIL PROTECTED] írta: > > So wat should I do ?? > > > You should do this: > > print type(Function),type(Description) > raise SystemExit > > Instead of this: > > print template % (ID, IID, Function[:10], Description[:10],ErrorNumber, > StatusCD) > > Then probably you will see: > > > > instead of > > > > > or something similar. (Of course in your case, it can be 'float instead of > list' or 'dictionary instead of tuple' etc.) > > Then you should debug your program and find out why the 'Function' and > 'Description' objects are not string but int. > > > Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: unsubscriptable object
I did the same, The function type is < NoneType> and the description type is so how can i print a part of this 2 output. These values are returned by database. Thanks Retheesh Laszlo Nagy wrote: > [EMAIL PROTECTED] írta: > > So wat should I do ?? > > > You should do this: > > print type(Function),type(Description) > raise SystemExit > > Instead of this: > > print template % (ID, IID, Function[:10], Description[:10],ErrorNumber, > StatusCD) > > Then probably you will see: > > > > instead of > > > > > or something similar. (Of course in your case, it can be 'float instead of > list' or 'dictionary instead of tuple' etc.) > > Then you should debug your program and find out why the 'Function' and > 'Description' objects are not string but int. > > > Laszlo -- http://mail.python.org/mailman/listinfo/python-list
a -very- case sensitive search
Hi, I am pretty new to Python and I want to make a script that will search for the following options: 1) words made of uppercase characters -only- (like "YES") 2) words made of lowercase character -only- (like "yes") 3) and words with only the first letter capitalized (like "Yes") * and I need to do all these considering the fact that not all letters are indeed English letters. I went through different documention section but couldn't find a right condition, function or method for it. Suggestions will be very much appriciated... --Ola -- http://mail.python.org/mailman/listinfo/python-list
Re: a -very- case sensitive search
Thank you! This was really helpful. Also the data bit about .istitle() was the missinng piece of the puzzle for me... So now my script is nice and working :) And as beside the point, yes I am from Israel, and no, we don't have uper case and lower case letters. Hebrew has only one set of letters. So my script was actualy for the english letters inside the hebrew text... --Ola Paul McGuire כתב: > "Ola K" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi, > > I am pretty new to Python and I want to make a script that will search > > for the following options: > > 1) words made of uppercase characters -only- (like "YES") > > 2) words made of lowercase character -only- (like "yes") > > 3) and words with only the first letter capitalized (like "Yes") > > * and I need to do all these considering the fact that not all letters > > are indeed English letters. > > > > I went through different documention section but couldn't find a right > > condition, function or method for it. > > Suggestions will be very much appriciated... > > --Ola > > > Ola, > > You may be new to Python, but are you new to regular expressions too? I am > no wiz at them, but here is a script that takes a stab at what you are > trying to do. (For more regular expression info, see > http://www.amk.ca/python/howto/regex/.) > > The script has these steps: > - create strings containing all unicode chars that are considered "lower" > and "upper", using the unicode.is* methods > - use these strings to construct 3 regular expressions (or "re"s), one for > words of all lowercase letters, one for words of all uppercase letters, and > one for words that start with an uppercase letter followed by at least one > lowercase letter. > - use each re to search the string u"YES yes Yes", and print the found > matches > > I've used unicode strings throughout, so this should be applicable to your > text consisting of letters beyond the basic Latin set (since Outlook Express > is trying to install Israeli fonts when reading your post, I assume these > are the characters you are trying to handle). You may have to do some setup > of your locale for proper handling of unicode.isupper, etc., but I hope this > gives you a jump start on your problem. > > -- Paul > > > import sys > import re > > uppers = u"".join( unichr(i) for i in range(sys.maxunicode) > if unichr(i).isupper() ) > lowers = u"".join( unichr(i) for i in range(sys.maxunicode) > if unichr(i).islower() ) > > allUpperRe = ur"\b[%s]+\b" % uppers > allLowerRe = ur"\b[%s]+\b" % lowers > capWordRe = ur"\b[%s][%s]+\b" % (uppers,lowers) > > regexes = [ > (allUpperRe, "all upper"), > (allLowerRe, "all lower"), > (capWordRe, "title case"), > ] > for reString,label in regexes: > reg = re.compile(reString) > result = reg.findall(u" YES yes Yes ") > print label,":",result > > Prints: > all upper : [u'YES'] > all lower : [u'yes'] > title case : [u'Yes'] -- http://mail.python.org/mailman/listinfo/python-list
Search & Replace in MS Word Puzzle
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here, the string at the beginning explains what it does: '''A script for MS Word which does the following: 1) Assigns all Hebrew italic characters "Italic" character style. 2) Assigns all Hebrew bold characters "Bold" character style. 2) Assign all English US characters "English Text" (can be regular, Italic, or Bold) ''' import win32com.client #setting up shortcuts word = win32com.client.Dispatch("Word.Application") doc = word.ActiveDocument find = doc.Content.Find w=win32com.client.constants #creating the needed styles if not there already if "Italic" not in doc.Styles: doc.Styles.Add("Italic",w.wdStyleTypeCharacter) #"ItalicBi" is the same as "Italic", but for languages that go Right to Left. doc.Styles("Italic").Font.ItalicBi = True print "Italic style was created" if "Bold" not in doc.Styles: doc.Styles.Add("Bold",w.wdStyleTypeCharacter) doc.Styles("Bold").Font.BoldBi = True print "Bold style was created" if "English Text" not in doc.Styles: doc.Styles.Add("English Text", w.wdStyleTypeCharacter) doc.Styles("English Text").Font.Scaling = 80 print "English Text style was created" if "English Text Italic" not in doc.Styles: doc.Styles.Add("English Text Italic", w.wdStyleTypeCharacter) doc.Styles("English Text Italic").BaseStyle = "English Text" doc.Styles("English Text").Font.Italic = True print "English Text Italic style was created" if "English Text Bold" not in doc.Styles: doc.Styles.Add("English Text Bold", w.wdStyleTypeCharacter) doc.Styles("English Text Bold").BaseStyle = "English Text" doc.Styles("English Text").Font.Bold = True print "English Text Bold style was created" #Search & Replacing Hebrew Italics find.ClearFormatting() find.Font.Italic = True find.Format = True find.LanguageID = w.wdHebrew find.Replacement.ClearFormatting() find.Replacement.Style = doc.Styles("Italic") find.Execute(Forward=True, Replace=w.wdReplaceAll, FindText='', ReplaceWith='') print "Italic style was checked" #Search & Replacing Hebrew Bolds find.ClearFormatting() find.Font.Bold = True find.Format = True find.LanguageID = w.wdHebrew find.Replacement.ClearFormatting() find.Replacement.Style = doc.Styles("Bold") find.Execute(Forward=True, Replace=w.wdReplaceAll, FindText='', ReplaceWith='') print "Bold style was checked" #Search & Replacing English Regulars find.ClearFormatting() find.LanguageID = w.wdEnglishUS find.Font.Italic = False find.Font.Bold = False find.Replacement.ClearFormatting() find.Replacement.Style = doc.Styles("English Text") find.Execute(Forward=True, Replace=w.wdReplaceAll, FindText='', ReplaceWith='') print "English Text style was checked" #Search & Replacing English Italics find.ClearFormatting() find.LanguageID = w.wdEnglishUS find.Font.Italic = True find.Replacement.ClearFormatting() find.Replacement.Style = doc.Styles("English Text Italic") find.Execute(Forward=True, Replace=w.wdReplaceAll, FindText='', ReplaceWith='') print "English Text Italic style was checked" #Search & Replacing English Bolds find.ClearFormatting() find.LanguageID = w.wdEnglishUS find.Font.Bold = True find.Replacement.ClearFormatting() find.Replacement.Style = doc.Styles("English Text Bold") find.Execute(Forward=True, Replace=w.wdReplaceAll, FindText='', ReplaceWith='') print "English Text Bold style was checked" print "We are done." word.Visible=1 --Code end here So generally speaking this script works quite nicely, BUT: 1. Despite this sort of conditions: " if "Italic" not in doc.Styles: " if this style already exists I get an error, and the program stops. Any idea how can that be?... 2. The replacement of the English characters doesn't seem to work very well. It either assigns all English characters "English Text Bold", or "English Text Italic" and with no apparent reason. ? 3. The command " word.Visible=1 " doesn't work anymore. I say "anymore" because it used to work, but later I ran "COM Makepy Utility" on "Microsoft Word 10 Object Library (8.2)" and since then it stopped working. On Excel, for example, I never ran Makepy and this commands works fine for it. Any idea on this one?... 4. In the end of this long weekend I was pretty satisfied with my script (even if not fully functioning) and used PY2EXE to make it an .exe file so that I can use it in my work place. But alas, that .exe file does not work because it doesn't recognize any of win32com client constants. Such as "wdStyleTypeCharacter", or "wdEnglishUS" How can I solve this one? Advice will be very appreciated. --Ola -- http://mail.python.org/mailman/listinfo/python-list
share function argument between subsequent calls but not between class instances!
Hi, given the following example class class Test: def f(self,a, L=[]): L.append(a) return L and the following statements a = Test() a.f(0) a.f(0) a.f(0) b = Test() b.f(0) this is the output I would like to have (i.e., expect) >>> a = Test() >>> a.f(0) [0] >>> a.f(0) [0, 0] >>> a.f(0) [0, 0, 0] >>> b = Test() >>> b.f(0) [0] But this is what I get: >>> a = Test() >>> a.f(0) [0] >>> a.f(0) [0, 0] >>> a.f(0) [0, 0, 0] >>> b = Test() >>> b.f(0) [0, 0, 0, 0] as you can see, the b.f method shares L with a.f. How can I avoid this without using eg. self.L in an __init__? Thanks in advance, Karel. -- http://mail.python.org/mailman/listinfo/python-list
Embedding interactive interpreter
Hi. I am trying to embed an interactive interpreter in a C++ application. I need to capture the output of int PyRun_InteractiveOne(FILE *fp, const char *filename). Is redirecting sys.stdout and sys.stderr after initializing the interpreter the best way to do this? Thanks, Ryan -- http://mail.python.org/mailman/listinfo/python-list
problem with pickle
hello everybody I've just started learning python . i stumbled upon this broad spectrum function 'pickle' but it is not getting executed as it should this is what the python interpreter returns on giving the basic command >>>pickle.dump(x,f) where x is a tuple and f is a file object Traceback (most recent call last): File "", line 1, in ? NameError: name 'pickle' is not defined kindly elucidate what's wrong thanks -- http://mail.python.org/mailman/listinfo/python-list
Running Python with XAMPP
Hello everyone! I just installed Python 2.5 and i want to use Python to build websites. I could load mod_python successfully with Apache but i fail to let the .py-files to be executed! In /htdocs/python i got my test file: [code=python.py] from mod_python import apache def index(req): req.content_type = "text/html" req.write("") req.write("Python is running with mod_python...") return apache.OK [/code] And then i got the following code in my httpd.conf: [code] AddHandler mod_python .py pythonHandler index pythonDebug On [/code] But when i type "http://localhost/python/python.py"; it won't execute! My browser just shows me the source code. :-( Please, can anyone tell me what i have to do? Thanks in advance! ~ Mathias -- http://mail.python.org/mailman/listinfo/python-list
mysql "rows affected"
using MySQLdb, I do cursor.execute("update...") How can I tell how many rows were affected ? Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: mysql "rows affected"
John Nagle wrote: > Carl K wrote: >> using MySQLdb, I do cursor.execute("update...") >> >> How can I tell how many rows were affected ? >> >> Carl K > > cursor = db.cursor() # get cursor > cursor.execute(sqlstatement, argtuple) # do command > rowsaffected = cursor.rowcount # get count of rows affected > cursor.close() # close cursor > db.commit() # commit transaction > > John Nagle cursor.rowcount - bingo. Thanks a bunch. Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: mysql "rows affected"
Dennis Lee Bieber wrote: > On Thu, 26 Apr 2007 18:18:57 -0700, John Nagle <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Carl K wrote: >>> using MySQLdb, I do cursor.execute("update...") >>> >>> How can I tell how many rows were affected ? >>> >>> Carl K >> cursor = db.cursor() # get cursor >> cursor.execute(sqlstatement, argtuple) # do command > > According to the documentation, it may be possible to get the result > with > > rws = cursor.execute(...) > > > -=-=-=-=-=-=- >>>> help(cr.execute) > Help on method execute in module MySQLdb.cursors: > > execute(self, query, args=None) method of MySQLdb.cursors.Cursor > instance > Execute a query. > > query -- string, query to execute on server > args -- optional sequence or mapping, parameters to use with query. > > Note: If args is a sequence, then %s must be used as the > parameter placeholder in the query. If a mapping is used, > %(key)s must be used as the placeholder. > > Returns long integer rows affected, if any > > -=-=-=-=-=-=- hey look at that. Thanks. Carl K -- http://mail.python.org/mailman/listinfo/python-list
ctree data
A friend needs to convert c-tree plus data to MySql. I can to the "to MySql part, but need some help with the "from c-tree." If I just wanted to get this done, I would hunt down the ODBC driver and use some MSy thing. But I am trying to hone my Python skills, but right now I am in over my head, thus this post. I think with a little boost I will be able to make it all come together. (well, little boost may be an understatement - I have no clue how close/far I am from what I need.) My searching around has come up with a few ways to use Python to read the data: 1. pull what I need from some other py code that uses c-tree: http://oltp-platform.cvs.sourceforge.net/oltp-platform/OLTPP/services/PythonScript/PythonTranslate.h?view=markup http://oltp-platform.cvs.sourceforge.net/oltp-platform/OLTPP/scripts/TestZipCodes.py?view=markup 12 a,b,c = ZipCode.Get() 13 print "Zip code is ", a 14 print "State is ", b 15 print "City is ", c I am sure this is what I want. I just haven't figured out where to start. 2. "Pyrex" to create Python bindings to C API with minimal C knowledge. I took C and did a few little utilities on my own in the 90's. plus I can make a tarball. today I am not sure I even qualify for "minimal." 3. the C API is present as a shared object (.so), use it from Python with ctypes. I have no idea what that means. 4. odbc - I am actually not thrilled about using the ctree odbc driver in any environment, because someone else who tried to use it on some other data a few years ago said it was flaky, and support was next to useless. 5, get someone who knows perl to do it using http://cpan.uwinnipeg.ca/htdocs/Db-Ctree/Db/Ctree.html - This just shows what lengths I am willing to go to. but I really don't want to start learning perl. TIA Carl K -- http://mail.python.org/mailman/listinfo/python-list
installing cx_Oracle.
I am trying to use this: http://python.net/crew/atuining/cx_Oracle/html/cx_Oracle.html it is a real module, right? sudo easy_install cx_Oracle did not easy_install cx_Oracle. http://www.python.org/pypi/cx_Oracle/4.3.1 doesn't give me any clue. I got the source from http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-4.3.1.tar.gz?download [EMAIL PROTECTED]:~/a/cx_Oracle-4.3.1$ python setup.py build Traceback (most recent call last): File "setup.py", line 36, in ? oracleHome = os.environ["ORACLE_HOME"] File "/usr/lib/python2.4/UserDict.py", line 17, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: 'ORACLE_HOME' Now I don't really know whos problem this is. Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: installing cx_Oracle.
Getting closer, thanks Bill and Diez. $ export ORACLE_HOME $ ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client $ python setup.py build $ sudo python setup.py install $ python -c "import cx_Oracle" Traceback (most recent call last): File "", line 1, in ? ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory guessing I need to add /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ to some path? btw - anyone know of a .deb that will install this? Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: installing cx_Oracle.
Bill Scherer wrote: > Carl K wrote: >> Getting closer, thanks Bill and Diez. >> >> $ export ORACLE_HOME >> $ ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client >> $ python setup.py build >> $ sudo python setup.py install >> >> $ python -c "import cx_Oracle" >> Traceback (most recent call last): >>File "", line 1, in ? >> ImportError: libclntsh.so.10.1: cannot open shared object file: No >> such file or directory >> >> guessing I need to add >> /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ >> to some path? >> > You can `export > LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib` > > or (assuming a recent RedHat linux (or similar) now), put that path in a > file, /etc/ld.so.conf.d/oracle.conf > > and run /sbin/ldconfig > > You'll find the latter operation to be persistent, and the former is not. >> btw - anyone know of a .deb that will install this? >> >> Carl K >> bingo. [EMAIL PROTECTED]:~/a/cx_Oracle-4.3.1$ python Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle >>> connection = cx_Oracle.connect('testuserA', 'pw', 'nf55') >>> cursor = connection.cursor() >>> cursor.execute("select * from tbl1") [, , ] >>> rows=cursor.fetchall() >>> rows [(1, 'a ', 1.01), (2, 'a ', 1.02), (3, 'a ', 1.03)] Thanks - now I can get to the real problem: client side join/order by :) But I have already done it in MySql, so this should be the easy part... Thanks again. Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: installing cx_Oracle.
Dennis Lee Bieber wrote: > On Thu, 24 May 2007 09:07:07 -0500, Carl K <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Getting closer, thanks Bill and Diez. >> >> $ export ORACLE_HOME >> $ ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client > > Don't those lines need to be reversed? Set the variable in the > current shell, and /then/ export it? whoops - I may have cut/pasted too fast. Carl K -- http://mail.python.org/mailman/listinfo/python-list
◘►Access FREE Satellite TV on your PC or Laptop◄◘
Legally Access 1000's of Television Channels From All Over The World Watch all your favorite shows on your Computer! Save 1000's of $$$ over many years on cable and satellite bills. INSTANT DOWNLOAD Learn More About it at Link below: http://tvonpc.cq.bz -- http://mail.python.org/mailman/listinfo/python-list
attribute save restore
Is there a more elegant way of coding this: x=o.p # save .p o.p=0 o.m() o.p=x # restore .p seems very push/pop to me - like there should be a way that doesn't need a var (x) or the save/set lines should be done in one command. (personally I think .m would better be implemented by passing in a parameter, but that isn't my choice.) Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: attribute save restore
Steven Bethard wrote: > Carl K wrote: >> Is there a more elegant way of coding this: >> >> x=o.p # save .p >> o.p=0 >> o.m() >> o.p=x # restore .p >> >> seems very push/pop to me - like there should be a way that doesn't >> need a var (x) or the save/set lines should be done in one command. > > With the appropriate context manger, you could write this as:: > > with setting(o, 'p', 2): > o.m() > > Here's the code:: > > >>> from __future__ import with_statement > >>> @contextlib.contextmanager > ... def setting(obj, name, value): > ... old_value = getattr(obj, name) > ... setattr(obj, name, value) > ... try: > ... yield obj > ... finally: > ... setattr(obj, name, old_value) > ... > >>> class C(object): > ... def __init__(self, x): > ... self.x = x > ... def m(self): > ... print self.x > ... > >>> c = C(1) > >>> with setting(c, 'x', 2): > ... c.m() > ... > 2 > >>> print c.x > 1 > > Of course, that just wraps up the same push/pop behavior you're doing > into a context manager. Thanks. As I was eating lunch I came up with: x,o.p = o.p,0 Which I am pretty sure is just bad :) I need to cut back on the hot sauce. > >> (personally I think .m would better be implemented by passing in a >> parameter, but that isn't my choice.) > > Yep, that's the right answer. You should complain to whoever created > this API. Will do. Something is buggy anyway, so as long as I am commenting... Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: Python editor/IDE on Linux?
Jack wrote: > I wonder what everybody uses for Python editor/IDE on Linux? > I use PyScripter on Windows, which is very good. Not sure if > there's something handy like that on Linux. I need to do some > development work on Linux and the distro I am using is Xubuntu. > > I use spe - it is in universe. Has some rough edges, but in general I like it enough to recommend it. Carl K -- http://mail.python.org/mailman/listinfo/python-list
looking for ocbc example
I am sure this is what I want: http://www.python.org/topics/database/docs.html "The documentation for the PythonWin ODBC module." but it is 404. google isn't being nice. Anyone know where I can find some simple examples? I have used odbc in other environments, so just need to know what modules, and the lines to connect and execute a sql command. It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference? Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: int to str in list elements..
1. Use a generator expression: b = ",".join(str(i) for i in a) or 2. Use imap from itertools import imap b = ",".join(imap(str, a)) -- http://mail.python.org/mailman/listinfo/python-list
Displaying future times
I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module http://www.purecode.com/~tsatter/python/README.txt (at that URL) with a function that takes seconds from the epoch and a time zone and returns what is basically a datetime object. My question is how to I display the seconds from the epoch for a datetime object (which will be a datetime in the future) for the UTC timezone? -- http://mail.python.org/mailman/listinfo/python-list
Displaying future times
I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module http://www.purecode.com/~tsatter/python/README.txt (at that URL) with a function that takes seconds from the epoch and a time zone and returns what is basically a datetime object. My question is how to I display the seconds from the epoch for a datetime object (which will be a datetime in the future) for the UTC timezone? -- http://mail.python.org/mailman/listinfo/python-list
Re: Displaying future times
On Oct 17, 1:52 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 17 Oct 2007 12:20:06 +, ryan k wrote: > > I have a schedule of times in the future that I want to display in a > > timezone the user sets. There is a useful module > >http://www.purecode.com/~tsatter/python/README.txt(at that URL) with a > > function that takes seconds from the epoch and a time zone and returns > > what is basically a datetime object. > > > My question is how to I display the seconds from the epoch for a > > datetime object (which will be a datetime in the future) for the UTC > > timezone? > > Is this a trick question? Won't the answer be "The same way you would for > a datetime in the past"? > > To get the number of seconds from the epoch, see the function timegm() in > the calendar module. > > -- > Steven. Not a trick question at all... Cheers. -- http://mail.python.org/mailman/listinfo/python-list
text wrapping help
I'm trying to text wrap a string but not using the textwrap module. I have 24x9 "matrix" and the string needs to be text wrapped according to those dimensions. Is there a known algorithm for this? Maybe some kind of regular expression? I'm having difficulty programming the algorithm. Thanks, Ryan -- http://mail.python.org/mailman/listinfo/python-list
Re: text wrapping help
Okay, I was a little vague in my last post...the matrix is like a Wheel of Fortune board and it knows nothing about newlines. After 24 characters it spills over onto the next line. Here is what I came up with: ## Wrap Text def wrap_text(in_str, chars_line): """ wrap text """ spaces = 0 new_str = "" tmp_str = "" while True: tmp_str = in_str[:chars_line] if tmp_str[chars_line-1].isspace(): new_str += tmp_str else: spaces = 0 for ch in reversed(tmp_str): if ch.isspace(): break spaces += 1 tmp_str = tmp_str[:chars_line-spaces] tmp_str += " " * spaces new_str += tmp_str in_str = in_str[chars_line-spaces:] if len(in_str) <= chars_line: new_str += " " + in_str break return new_str if __name__ == '__main__': sample_text = """Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet.""" print wrap_text(sample_text, 24) It doesn't even run but when I go through it interactively it seems okay. Once again, any help is appreciated. On Feb 28, 7:06 pm, "Ryan K" <[EMAIL PROTECTED]> wrote: > I'm trying to text wrap a string but not using the textwrap module. I > have 24x9 "matrix" and the string needs to be text wrapped according > to those dimensions. Is there a known algorithm for this? Maybe some > kind of regular expression? I'm having difficulty programming the > algorithm. Thanks, > Ryan -- http://mail.python.org/mailman/listinfo/python-list
Re: text wrapping help
That works great but I need to replace the newlines with 24-(the index of the \n) spaces. On Feb 28, 8:27 pm, [EMAIL PROTECTED] wrote: > On Feb 28, 4:06 pm, "Ryan K" <[EMAIL PROTECTED]> wrote: > > > I'm trying to text wrap a string but not using the textwrap module. I > > have 24x9 "matrix" and the string needs to be text wrapped according > > to those dimensions. Is there a known algorithm for this? Maybe some > > kind of regular expression? I'm having difficulty programming the > > algorithm. > > Try: > > import re > sample_text = """Personal firewall software may warn about the > connection IDLE makes to its subprocess using this computer's internal > loopback interface. This connection is not visible on any external > interface and no data is sent to or received from the Internet.""" > > # assume 24 is sufficiently wide: > > lines = map(lambda x: x.rstrip(), > re.findall(r'.{1,24}(?:(?<=\S)\s|$)', sample_text.replace("\n", " "))) > > print "\n".join(lines) > > -- > Hope this helps, > Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for ocbc example
jay graves wrote: > On Sep 21, 2:43 am, Tim Golden <[EMAIL PROTECTED]> wrote: >> Carl K wrote: >>> It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the >>> difference? >> In short, pyodbc is open source; mxOdbc requires a commercial license. >> pyodbc is a newcomer, but appears to work for everything I've thrown >> at it (which is not much). mxOdbc has been around longer, and is sure >> to be a more mature product. It may offer more features & functionality. > > There is also a brand new module 'ceODBC'. > http://ceodbc.sourceforge.net/ > > I haven't used it yet but I want to give it a try. I tried it, and it worked better than pyodbc. (better is not exactly right. there was some weird bug in the ctree odbc driver, and the author of ceODBC gave me a workaround.) Carl K Carl K -- http://mail.python.org/mailman/listinfo/python-list
mac dashboad
How do I hang an app off the mac dashboard? The goal is a python version of Weatherbug. something like: read xml data from a URL, display some numbers, mouse over shows more details Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: mac dashboad
ianaré wrote: > On Dec 21, 12:37 pm, Carl K <[EMAIL PROTECTED]> wrote: >> How do I hang an app off the mac dashboard? >> >> The goal is a python version of Weatherbug. >> >> something like: >> read xml data from a URL, >> display some numbers, >> mouse over shows more details >> >> Carl K > > What is the dashboard - is it anything like the taskbar in windows/ > Gnome? If it is, take a look at this: > > http://www.wxwidgets.org/manuals/2.6.3/wx_wxtaskbaricon.html Yes. But I don't want to rely on wx - trying to use just native mac python (whatever they ship with) Carl K -- http://mail.python.org/mailman/listinfo/python-list
Re: mac dashboad
Chris Mellon wrote: > On Dec 21, 2007 3:25 PM, Carl K <[EMAIL PROTECTED]> wrote: >> ianaré wrote: >>> On Dec 21, 12:37 pm, Carl K <[EMAIL PROTECTED]> wrote: >>>> How do I hang an app off the mac dashboard? >>>> >>>> The goal is a python version of Weatherbug. >>>> >>>> something like: >>>> read xml data from a URL, >>>> display some numbers, >>>> mouse over shows more details >>>> >>>> Carl K >>> What is the dashboard - is it anything like the taskbar in windows/ >>> Gnome? If it is, take a look at this: >>> >>> http://www.wxwidgets.org/manuals/2.6.3/wx_wxtaskbaricon.html >> Yes. But I don't want to rely on wx - trying to use just native mac python >> (whatever they ship with) >> > > > Dashboard widgets are written using HTML and Javascript. They are > rendered by a WebKit instance which, as far as I know, has no > mechanism for Python scripting. Unless it does, you can't write a > widget in Python, and even so you wouldn't use wx (or any other GUI > toolkit) to do so - your display medium is HTML and the Canvas object. > There's lots of articles on developer.apple.com about writing > Dashboard widgets. bah. takes the fun out of it. Thanks, Carl K -- http://mail.python.org/mailman/listinfo/python-list