Re: ncurses programming
I don't know too much about (n)curses, but I feel that it's worth pointing out that Python has a (built-in?) module named `curses` that supports ncurses as of Python version 1.6. I don't think it'd be necessary to learn how to use ncurses in C first, though. The Python docs for the curses module is pretty straight forward, and they link to what I feel is a pretty good tutorial on the module. Py Docs: http://docs.python.org/lib/module-curses.html Tutorial: http://www.python.org/doc/howto/curses/curses.html Also, if you choose to take the Python module route, you might want to consider using the curses.wrapper module to ensure that if any errors happen, it will close out curses all of the way instead of allowing curses to screw up your console window. Wish I could be of more help. Any questions and I'll gladly look into it to the best of my abilities. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: ncurses programming
I don't know too much about (n)curses, but I feel that it's worth pointing out that Python has a (built-in?) module named `curses` that supports ncurses as of Python version 1.6. I don't think it'd be necessary to learn how to use ncurses in C first, though. The Python docs for the curses module is pretty straight forward, and they link to what I feel is a pretty good tutorial on the module. Py Docs: http://docs.python.org/lib/module-curses.html Tutorial: http://www.python.org/doc/howto/curses/curses.html Also, if you choose to take the Python module route, you might want to consider using the curses.wrapper module to ensure that if any errors happen, it will close out curses all of the way instead of allowing curses to screw up your console window. Wish I could be of more help. Any questions and I'll gladly look into it to the best of my abilities. -Wes -- http://mail.python.org/mailman/listinfo/python-list
__call__ in module?
I have a feeling that this is highly unlikely, but does anyone in here know if it's possible to directly call a module, or will I have to wrap it up in a class? i.e., import MyMod MyMod.whatever = "Hi?" MyMod("meow mix") Thanks in advance -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: __call__ in module?
My thanks to you and Fredrik Lundh for the quality replies. however much so, I appreciate your moreso descriptive reply. I probably should've been a little more specific in my original query, and have stated that I *did* try it before I posted here asking for help. I was just hoping somebody would be able to prove my test wrong. Oh well, have a good day -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: __call__ in module?
My thanks to you and Fredrik Lundh for the quality replies. however much so, I appreciate your moreso descriptive reply. I probably should've been a little more specific in my original query, and have stated that I *did* try it before I posted here asking for help. I was just hoping somebody would be able to prove my test wrong. Oh well, have a good day -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: __call__ in module?
Thanks for this information. It'd really be interesting to see how well this works for the code I wish to apply it to. Thanks again and have a GREAT day. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: zlib decode fails with -5
I don't mean this harshly, but have you tried recompressing the data to see if you may have had a bad data set? If it still fails, then I'm really not sure why/how zlib decides that there isn't enough room in the output buffer. "Z_BUF_ERROR if there was not enough room in the output buffer" Sorry I couldn't be of much assistance on this matter. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Overhead of individual python apps
First, please don't get so upset at people's replies (if you weren't upset, that's how it was coming across, so my apologies). No matter what newsgroup/forum you go to, there's always someone who's going to suggest something like that. Anyways, I'm fairly certain there are some minimalistic Python variants designed for older computers and such. Maybe something to check into? HTH, -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: FarPy GUIE v0.1
Walter Purvis wrote: > Is there a URL? Haha. Google :) http://farpy.holev.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: 1 Million users.. I can't Scale!!
If you have that many users, I don't know if Python really is suited well for such a large scale application. Perhaps it'd be better suited to do CPU intensive tasks it in a compiled language so you can max out proformance and then possibly use a UNIX-style socket to send/execute instructions to the Python interface, if necessary. Sorry I really couldn't be of much help -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
> Do you know any language that has real private and protected attributes? As long as the values are stored in memory, there's always a way to alter and access them. So, IMHO, no program can have truely private/protected values. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get any available port
Hmm...perhaps he is trying to do a transfer thing like many chat programs do. Instead of sending large files across a server, you "Direct Connect" and send the file directly. :shrugs: -- http://mail.python.org/mailman/listinfo/python-list
wxPython equiv. to tag_configure
Hi all. I'm trying to do a system where I'm working on a set of windows for both Tkinter and wxPython, and have come across a lovely little bump in the road. Tkinter's Text object has tag_* methods, but I don't know of a good way to do tag-related stuff with wxPython. In the wxWidgets manual, I see a wxHtmlWindow object, but nothing like that seems to exist when I dir() wxPython. Does anyone have any suggestions? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython equiv. to tag_configure
Errm, can you slap me please? :X Either way, thank you soo much :) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: how to keep a socket listening?
I think your problem /may/ be in the following line of code: sa.listen(1) I believe what's happening is that the listen() creates a decremental counter of the number of connections to accept. Once it decrements to 0, it won't accept any more connections. (I'm not at all sure, but that sounds like what it's doing.) One thing that I have noted is that once I am done with some internet program, the connection that program created is left in the waiting state. This might explain why, when you close your application and open it back up again a short amount of time later, the connection is refused. Another thought on this matter is that your end may be closing the connection, but the daemon end might not be closing the connection, so the listen counter may not increment back up to say "Hey, I'm available for another connection." Nevertheless, I'm also relatively new to Sockets, so my guess is probably just as good as your guess. :P (Hell, I couldn't get them fully right away, and read that it was easier to use asyncore.dispatcher for a daemon, so I'm using that!) If you find out the problem, please post it up here for all to learn from :) Oh, and just a suggestion, do something like a 'netstat -a -p --inet' on the daemon end. (Might not be the completely correct command =\) Hope that helps -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: how to keep a socket listening?
Heh, like I said. I was not at all sure. :P Nevertheless, could this be the problem? =\ -- http://mail.python.org/mailman/listinfo/python-list
Threading Question
I've used python for a while now, and am startting to dig into threads and sockets (using asyncore/asynchat). Through all this, I've been using the -v option on python to generate verbose output and try to pinpoint any potential problems...however, one warning is eluding me as to it's cause/resolution. > > > > > > PyThreadState_Clear: warning: thread still has a frame This warning seems to make little sense to me (even though it probably shouldn't). Can anyone guide me as to what it is and how I could try and make a resolution. Many thanks in adv. -Wes P.S.: If needed, I will gladly toss a shortened version of the code up for all to see. -- http://mail.python.org/mailman/listinfo/python-list
Re: Favorite non-python language trick?
Eh, just figured it'd be worth noting...map, filter, and reduce should be possible with the extended list syntaxes. Well, filter I know is, but hte others /should/ be possible. filter(lambda: <>, <>) [some_var for some_var in <> if <>] Honestly, though, I hope they don't drop the map functions and such. That's one of the stronger functions of the language (IMO). -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Favorite non-python language trick?
Hmm...I think it's time I do better justice to what I previously wrote. http://www.artima.com/weblogs/viewpost.jsp?thread=98196 The above article was linked by Python's PEP... -- http://mail.python.org/mailman/listinfo/python-list
Re: Favorite non-python language trick?
Sorry, I realized that shortly after my post =X -- http://mail.python.org/mailman/listinfo/python-list
Re: Should I use "if" or "try" (as a matter of speed)?
Honestly, I'm rather new to python, but my best bet would be to create some test code and time it. -- http://mail.python.org/mailman/listinfo/python-list
Re: pyo contains absolute paths
Python is compiling the files with absolute paths because it is much faster to load a file when you know where it is, than to have to find it and then load it. I'm guessing you're wondering this so you can distribute it compiled or such? If so, I wouldn't do that in the first place. Python's compiled files might be version/architecture dependant. -NcF -- http://mail.python.org/mailman/listinfo/python-list
Re: Odd behaviour of regexp module
To possibly clearify what the others have said, group() is the same as saying group(0). Group is, if I recall correctly, supposed to return the n-th subpattern from the regular expression (subpatterns, as you know, being indicated by parenthises). Hope that helps :) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
Honestly, I'm just using Python's own IDLE to do it all. It works rather well for my tastes :) -- http://mail.python.org/mailman/listinfo/python-list
Re: retrieving https pages
It might be checking the browser's User-agent. My best bet for you would to be to use something to record the headers your browser sends out, and mimic those in Python. If you look at the source code for urlopener (I think you can press Alt+M and type in "urlopener"), under the FancyURLopener definition, you should see something like self.add_headers (not on a box to check it right now, but it's in the constructer, I remember that much). Just set all the headers to send out (like your browser would) by setting that value from your script. i.e.: import urlopener urlopener = FancyURLopener() urlopener.add_headers = [('User-agent','blah'),('Header2','val'),('monkey','bone')] # do the other stuff here :P HTH -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?
I'm sure that nobody here is willing to write it for you. However, I believe that jkn was right in trying to get you to solve the problem. ;) You know what you need to do, but how are you going to do it? Create a flow chart ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: "Aliasing" an object's __str__ to a different method
In trying to develop a protocol for a current app I'm working on, I was using classes which inherited from object for my core packet, and using str(Message) to convert it to an encoded packet. However, I found that this did not work, and it drove me insane, so in a test file, I wrote the following code: class Whatever: ''' Supposed to be inheritable ''' def __init__(self): self.__str__ = self._encode # Dynamically set the __str__ from superclass(?) Well, suffice to say, having the class not inherit from object solved my problem, as I suspect it may solve yours. ;) I havn't a clue why it acts that way, however, I hope knowledge of my past experiances helps you also. Have a GREAT day :) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Simple Problem
I know I've seen this somewhere before, but does anyone know what the function to escape a string is? (i.e., encoding newline to "\n" and a chr(254) to "\xfe") (and visa-versa) Thanks for helping my ignorance :P -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Problem
Thank you all for your replies. The repr() solution wasn't exactly what I was looking for, as I wasn't planning on eval()ing it, but the (en|de)code solution was exactly what I was looking for. An extended thanks to Jp for informing me of the version compatibility :) Have a GREAT day :) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Import question
In file A, I have an instance of a class and then I import file B (import fileB as fb). In file B, I need to access file A's class instance. Is there anyway I can do this? (I hope that was descriptive enough :\) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Import question
Hmm...thanks for the replies. Judging by this, it looks like I might still be in a slight perdiciment with doing it all, but time will tell. I wish there were a way I could reference across multiple modules. Well, thanks for your help. Hopefully I'll be able to work out some *simple* solution for all of this. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Import question
I've got multiple instances I want globally available in the secondary modules, which can't easily be passed around with every function call without driving me nuts, so I wish to have all variables from the Main module passed to each of the other modules it creates. One such example would be in Main, we call the SettingsParse() function or whatever, which creates a Settings class storing all settings. This class needs to be readily accessible by extensions (dynamically loaded) and almost all other modules in the project. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Import question
Crap. Forgot to mention that in some instances, I do want the class definitions to create new instances and such. Sorry :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter and gnuplot module
Because Tkinter is for GUI development on systems, and thereof, there is no plugin for browsers, I do not believe it to be possible to use Tkinter in a client's browser. If gnuplot.py allows you to save a plot to disk or get the plot's image file as a binary string, it should be possible to send a plot to a client's web browser. HTH, -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Module Name Conflicts
Maybe what you're looking for is __import__()? >>> help(__import__) Help on built-in function __import__ in module __builtin__: __import__(...) __import__(name, globals, locals, fromlist) -> module Import a module. The globals are only used to determine the context; they are not modified. The locals are currently unused. The fromlist should be a list of names to emulate ``from name import ...'', or an empty list to emulate ``import name''. When importing a module from a package, note that __import__('A.B', ...) returns package A when fromlist is empty, but its submodule B when fromlist is not empty. -- http://mail.python.org/mailman/listinfo/python-list
Traceback Questions
I'm just beginning with tracebacks, building off of what I see in asyncore's compact_traceback code, in order to hopefully store all the values from the location in which the exception occured. I'm actually trying to make this into a python bug report system for my current project, and am seeking advice on how to use sys.exc_info()[2] better (the traceback element) Does anyone have any advice on how I'd preform a traceback-based bugreport-like system? The more I work on this, the more I'm confusing myself. :\ -Wes This is the code from which I'm slowly figuring out the traceback stuff: import sys,pprint a,b = 1,0 def mth(a,b): moo = a/b try: mth(a,b) except: pass tb = sys.exc_info()[2] assert tb def sprint(o): pprint.pprint(dict([(x, getattr(o, x)) for x in dir(o) if x[:2]!='__']), indent=2) sprint(tb) sprint(tb.tb_frame) sprint(tb.tb_frame.f_code) -- http://mail.python.org/mailman/listinfo/python-list
Re: Module Name Conflicts
I'm honestly not too sure how __import__ works, but I know you can provide a full path to it. Oh well, that was my best guess. I wish I could've been of more help. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: time.clock() problem under linux (precision=0.01s)
Woa, if you don't mind my asking, why do you do a time-cache on your messages? -- http://mail.python.org/mailman/listinfo/python-list
Re: Traceback Questions
Thanks man, I'll definately take a look into this and hopefully port it over and publish it. Have a GREAT day -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Module Name Conflicts
Heh, so long as it works. Sorry for the delay, I've been away for a bit ;P Hope it's all owrking out -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: encryption with python
Steve M wrote: > >My goal is to combine two different numbers and > encrypt them to create a new number that cann't be traced back to the > originals. > > Here's one: > def encrypt(x, y): > """Return a number that combines x and y but cannot be traced back > to them.""" > return x + y Or you can use sha1 so you can't do basic checks to find out. :) It seems to me like he's trying to do some DH like thing, so yea, he might rather a hash UNTESTED import sha1 def encrypt(x,y): ''' Return a number that combines x and y but cannot be traced back to them. Number returned is in xrange(2**24). ''' def _dosha(v): return sha1.new(str(v)).hexdigest() return int(_dosha(_dosha(x)+_dosha(y))[5:11],16) -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython MainLoop exception handling problem
Errm, maybe you could use the sys.excepthook function to catch the error and then print the details yourself from the traceback object. import sys def _exceptionhook(type, value, traceback): ''' your code here ''' sys.excepthook = _exceptionhook ((untested)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Database Scripts
Hmm...sorry to go a little off topic here, but I, also, have been striving to learn Python/MySQL for a while using MySQL's official thing. Can you please explain to me why one must use a cursor and can't just do an execute on the connction? :confused about the subject: -- http://mail.python.org/mailman/listinfo/python-list
Re: Firefox bug in webbrowser module on Ubuntu?!
This section is the cause of the problem: for browser in ("mozilla-firefox", "mozilla-firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Netscape(browser)) It's trying to load "mozilla-firefox" as the exec name instead of simply "firefox". A potential workaround *might* be to do this: import webbrowser if webbrowser._iscommand("firefox"): webbrowser.register("firefox", None, Netscape("firefox")) webbrowser.open("http://www.google.com/";) ((Untested)) Best of luck SPE - Stani's Python Editor wrote: > Hi, > > During optimizing SPE for Ubuntu, I found something strange. I have > Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not > working: > > >>> import webbrowser > >>> webbrowser.open("http://www.python.org";) > > It does not throw an exception, but is not able to launch a browser. > > Ubuntu ships with Firefox as its default browser, but it looks like it > is not recognized by the standard webbrowser module, instead it seems > to prefer Netscape, which is not installed: > > >>> import webbrowser > >>> webbrowser.browser > 'netscape' > > In the _browsers attribute there seems to be an entry for > 'mozilla-firefox', but doesn't seem to work > >>> webbrowser._browsers > {'galeon': [None, ], > 'mozilla': [None, ], > 'mozilla-firefox': [None, 0xb7d2612c>], 'w3m': [None, 0xb7d22fec>]} > > The tryorder is... > >>> webbrowser._tryorder > ['galeon', 'mozilla-firefox', 'mozilla', 'w3m'] > > As a workaround I check for the file '/usr/bin/firefox' and use a > os.system call. Of course a user could maybe install Netscape, but it > would be absurd that SPE would require Netscape. > > Is there a reason why this doesn't work? It looks like a bug. > > Stani > -- > http://pythonide.stani.be -- http://mail.python.org/mailman/listinfo/python-list
Python Args By Reference
Hello all, I was wondering if there was any way to pass arguments (integer and such) by reference (address of), rather than by value. Many thanks in advance. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Args By Reference
Ok, I'm relatively new to python (< 1 year experiance), yet I have had much experiance with other languages. I never really looked that deeply in the FAQ -- temporary lapse of stupidity(?). Thanks for the link, the concept seems to help. The two issues I am having in grasping all of this are as follows: 1) Being new to Python, terms like mutable and immutable. Although I have probably dealt with them in other languages, the terms by themselves are a little confusing, but managable overall, so this issue isn't so big. 2) LARGELY, my issue is as demonstrated by the following code. I was trying to accomplish an effect similar to what is possible in C. (Trying to make a pure-python FIPS-180-2 compliant implementation of the SHA-256 algorithm for more Python practice and to put into some code for a *trial* secure protocol.) Example C Code: #define P(a,b,c,d,e,f,g,h,x,K) \ { \ temp1 = h + S3(e) + F1(e,f,g) + K + x; \ temp2 = S2(a) + F0(a,b,c); \ d += temp1; h = temp1 + temp2; \ } Python Code: def P(a,b,c,d,e,f,g,h,x,K): temp1 = h + S3(e) + F1(e,f,g) + K + x temp2 = S2(a) + F0(a,b,c) d += temp1; h = temp1 + temp2 The reason why it'd be a pain to implement this by any of the methods provided in the Python FAQs is that SHA-256 rotates the variable order in the calls. Example code: P( A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98 ); P( H, A, B, C, D, E, F, G, W[ 1], 0x71374491 ); P( G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF ); P( F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5 ); P( E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B ); P( D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1 ); P( C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4 ); P( B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5 ); P( A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98 ); Since I cannot simply do it the way I had originally seen it, would there be an alternative method to proforming the operations that I am missing? Once again, many thanks for your time. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Args By Reference
As I fail to see how an array could be used in this (my own stupidity?), would you have any such example? For reference, I'm trying to translate this: http://www.cr0.net:8040/code/crypto/sha256/ (Inside sha256_process). Once again, thanks for the patience, I'm still picking up on all the little tid-bits. :) -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Args By Reference
Thanks to everyone for your assistance. I shall reread this a couple times and then try to make something that works. Many thanks and have a GREAT day. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: command to update a web page
I can't begin to know too much about this subject, but Python has a builtin httplib module which might be interesting to you. There is also a ftplib if that is how you want to do it. Python's documentation seems to have adequate examples on how to use the two modules. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: command to update a web page
Ugh. Correction. I can't begin to *act like* I know too much about this subject, ... -- http://mail.python.org/mailman/listinfo/python-list
"End Of Line" Confusion
I'm having an odd problem. I'm getting an error from IDLE saying "End Of Line detected while scanning single-quoted string." Odd thing is, it's not single-quoted, it's one of the doc-strings (if that's what you call them). In the following code (class name replaced with <<>>), the error is being highlighted as the hyphen joining "non" and "ASCII". class <<>>: <<>> def digest(): ''' char[28] digest ( ) Return the digest of the strings passed to the update() method so far. This is a 28-byte string which may contain non-ASCII characters, including null bytes. ''' raise NotImplementedError, 'digest() is not yet implemented.' Thanks in advance. -Wes -- http://mail.python.org/mailman/listinfo/python-list
Re: "End Of Line" Confusion
First off, my apologies...Google Groups doesn't seem to want to let me reply inline. I refrained from putting the name in there as it's potentially offensive (gotta love America). If you would aid you, I can send you the entire Python script via. email. Editor was IDLE on Slackware Linux using the ReiserFS Filesystem (not like the FS matters :P). There is not a quote mark in the docstring. What I posted for the function def is a straight-forward copy and paste. I'll try doing a hex-dump on the file and see if there's any odd bytes in there that shouldn't be. Yea, I think I did mean that. :P I hadn't yet even *begun* to work on the other areas...just working on the bit-wise math and what-not. -Wes -- http://mail.python.org/mailman/listinfo/python-list
GridBagSizer
Recently, I came across a presentation about wx.GridBagSizer while trying to look up more info to use it in an application, however, the presentation noted "Don't use GridBagSizer. Ever." Can anyone please explain to me why using GridBagSizer would be such a bad idea? Or is this only applicable when using XRC? Presentation URI: http://yergler.net/talks/desktopapps_uk/ Presentation Dated: 20APR05 Slide Number: 9 -- "Sanity and Cross-Platform XRC" -Ws -- http://mail.python.org/mailman/listinfo/python-list