Re: detect current timezone set by kde
I suggest to change /etc/timezone by invoking sudo tzselect. HTH, Gerald Pradnyesh Sawant schrieb: Hello, can someone please tell me how can I programatically detect the timezone information that has been set through kde? basically, I have a small pyqt4 app which shows the current time. however it shows me my system time (dunno where that is stored; basically it shows me time in IST). however, I'm right now in hk and would like the app to show me time in my current timezone (hong kong). Any guidelines how may I go about doing this? thanks a lot in advance :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Function Overloading and Python
Stefan Behnel schrieb: Allen Peloquin wrote: On Feb 24, 11:44 pm, Stefan Behnel [EMAIL PROTECTED] wrote: Allen Peloquin wrote: class B { fun(A x, A y, A z)... fun(A1 x, A y, A z)... } class B1 { fun(A1 x, A y, A z)... } Such that any previous behavior is inherited, but behaves polymorphically because of the single function name. Try something like this: class B(object): def fun(x,y,z): if isinstance(x, A1): return self._fun(x,y,z) # ... def _fun(x,y,z): # ... class B1(B): def _fun(x,y,z): # ... Stefan The problem is that I want to reuse the code of the parent classes through inheritance, otherwise this would work fine. Ok, I didn't see you were going to add new subtypes, that makes it more tricky to dispatch in the superclass. An alternative would be a more generic dispatcher pattern then: class B(object): _func_implementations = {} _dispatch = _func_implementations.get def func(self, x,y,z): self._dispatch(type(x), self._func)(self,x,y,z) def _func(self, x,y,z): # ... class B1(B): def _func(self, x,y,z): # ... B._func_implementations[B1] = B1._func Or, you could dispatch based on type /names/: class B(object): def func(self, x,y,z): func = getattr(self, _%s_func % type(x).__name__, self._func) func(x,y,z) def _A_func(self, x,y,z): # ... class B1(B): def _A1_func(self, x,y,z): # ... Stefan The BDFL came across that problem, too. You will find his thoughts here: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 The reference implementation for his solution is here: http://svn.python.org/view/sandbox/trunk/overload/ HTH, Gerald -- http://mail.python.org/mailman/listinfo/python-list
Re: Wanted: a python24 package for Python 2.3
Hi, You can't import subproces from future, only syntactic and semantic changes that will become standard feature in future python version can be activated that way. You can copy the subprocess module from python 2.4 somewhere where it will be found from python 2.3. At least subporcess is importable after that: --- snip --- [EMAIL PROTECTED]:~/ttt cp -av /usr/local/lib/python2.4/subprocess.py . »/usr/local/lib/python2.4/subprocess.py« - »./subprocess.py« [EMAIL PROTECTED]:~/ttt python2.3 Python 2.3.3 (#1, Jun 29 2004, 14:43:40) [GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2 Type help, copyright, credits or license for more information. import subprocess --- snip --- HTH, Gerald [EMAIL PROTECTED] schrieb: On Mar 20, 10:33 am, Jonathan Fine [EMAIL PROTECTED] wrote: Hello My problem is that I want a Python 2.4 module on a server that is running Python 2.3. I definitely want to use the 2.4 module, and I don't want to require the server to move to Python 2.4. More exactly, I am using subprocess, which is new in Python 2.4. What I am writing is something like === from subprocess import Popen === This will fail in Python 2.3, in which case I would like to write something like === try: from subprocess import Popen else ImportError: from somewhere_else import Popen === Put this way, it is clear (to me) that somewhere_else should be python24. In other words, I'm asking for a python24 package that contains all (or most) of the modules that are new to Python 2.4. I've looked around a bit, and it seems that this formulation of the solution is new. I wonder if anyone else has encountered this problem, or has comments on my solution. -- Jonathan You might be able to use the from future import SomeModule syntax to accomplish this, but I am not sure. Other than that, I would just recommend using the os.popen calls that are native to 2.3 Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: What's going on here?
Perhaps this piece of code might explain the behaviour: class C( object ): ... __slots__ = () ... o = C() o.a = 1 Traceback (most recent call last): File input, line 1, in ? AttributeError: 'C' object has no attribute 'a' object behaves like having an implict __slots__ attribute. HTH, Gerald Dale Strickland-Clark schrieb: Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. a = object() a object object at 0xb7bbd438 a.spam = 1 Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'object' object has no attribute 'spam' class b(object): ...pass ... a = b() a __main__.b object at 0xb7b4dcac a.spam = 1 What is subclassing adding to the class here? Why can't I assign to attributes of an instance of object? -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
AOL^H^H^H, me too. And it's paid better than C++ programming. HTH, Gerald Gabriel Genellina schrieb: At Monday 25/9/2006 20:09, walterbyrd wrote: I do. If so, I doubt there are many. That's why they get well paid :) (uhm, not really... :( ) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
AW: Python Embedding Questions
Hi Sean, perhaps it may help if you try Python 2.4.3 instead of 2.4.2. The release notes (http://www.python.org/download/releases/2.4.3/NEWS.txt) mention a lot of fixed bugs, including a segfault, that is similar to yours. Also all defects, that the folks at coverty (http://scan.coverity.com/) discovered with their static analysis tools, were fixed. Some answers: ad 1) I don't know, I did it twice and had similar problems as you. ad 2) AFAIK some games embed python, perhaps someone with more experience can proviode more explanation. HTH, Gerald Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Sean RyanGesendet: Dienstag, 1. August 2006 15:47An: python-list@python.orgBetreff: Python Embedding Questions Hi Guys,I have a couple of questions (and some concerns) about embedded python within my application.The application is a multi-threaded relatively complex c++ middleware Solaris 9 based application. A decision was made some time ago to provide some scripting capabilities and python was selected as the scripting language. As such, an interpreter was embedded within the application and threading was managed using PyEval_SaveThread, PyEval_RestoreThread and friends. The application switches between python and c++ many, many times during the execution of one business request - typically the flow will bec++ - python - c++ - python - c++ - python etc (roughly 60 - 40 split in terms of coverage)Originally python2.2.1 was embedded within the application - we now have a business case (performance being a primary driver) to move to python2.4(.2). We are having some stability issues (random core dumps), and in an attempt to track down the root cause I executed some stress tests under a purify environment and noticed the following :Python2.4.2 trips quite a few ABR (array bounds read) and FMR (free memory read) violations - python2.2.1 less so. purify notes the following as the innermost frames for a FMR. frame_dealloc [frameobject.c:76] PyEval_EvalCodeEx [ceval.c:2596] fast_function [ceval.c:3161]Is this a known issue with embedded python?I can trigger a similar crash with python 2.2.1 in a stress test environment.At this stage, I am getting very concerned about our implementation of embedded python and wondered :1. Is our use of python as an embedded language commonplace? 2. Does anyone have names of commerical applications that use python in this way3. Are we switching between python and c++ code too frequently (as many as 40 times in the execution of 1 request)4. Are there any consultants / contractors that we could engage to aid debugging our application / implementation.5. Are the warnings that purify is raising related to loss of stability in the application 6. Is python the correct choice for an embedded application (I am aware of the GIL issue)We need to make a concise decision very quickly regarding our use of python, and as such would appreciate the community's honest opinion.Best regards,Sean -- http://mail.python.org/mailman/listinfo/python-list
AW: Calling foreign functions from Python? ctypes?
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss something? Cya, Gerald -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Thomas Heller Gesendet: Dienstag, 10. Januar 2006 12:07 An: python-list@python.org Betreff: Re: Calling foreign functions from Python? ctypes? Delaney, Timothy (Tim) [EMAIL PROTECTED] writes: Thomas Heller wrote: As the author, I would be happy to see ctypes included with the standard Python build. I'm sure you know the magical incantation to get that to happen ... 1. Propose it on python-dev. 2. Commit to maintain it in the python core (or alternatively, propose to use the ElementTree maintenance method). 3. Get it accepted by Guido. 4. Do it. If a library isn't put forward for inclusion by the *author*, it won't be included - even if it's obviously best-of-breed. This was the sticking point for ElementTree (until the author found out what was going on and happily put it forward). I have done 1. I commit myself to 2. I promise to do 3., if someone convinces Guido to accept it (or whoever has the power to accept it). This is my response to Martin v. Löwis, who wrote: I don't have such a plan. To my knowledge, ctypes has never been contributed to Python, either, so its author apparently has no plan, either. It has been proposed to include it in core Python, but Guido didn't accept it. The thread starts here: http://mail.python.org/pipermail/python-dev/2004-January/thread.html#41814 And Guido's last word was this (see the end of the message): http://mail.python.org/pipermail/python-dev/2004-January/041856.html Thomas -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient 'tail' implementation
As long as memory mapped files are available, the fastest method is to map the whole file into memory and use the mappings rfind method to search for an end of line. The following code snippets may be usefull: reportFile = open( filename ) length = os.fstat( reportFile.fileno() ).st_size if length == 0: # Don't map zero length files, windows will barf continue try: mapping = mmap.mmap( reportFile.fileno(), length, mmap.MAP_PRIVATE, mmap.PROT_READ ) except AttributeError: mapping = mmap.mmap( reportFile.fileno(), 0, None, mmap.ACCESS_READ ) Then you can use mapping.rfind( os.linesep ) to find the end of the but last line and so on. This is very fast, because nearly all work is done by are rfind, which is implemented in C and the OS' paging logic. HTH, Gerald [EMAIL PROTECTED] schrieb: Mike Meyer wrote: It would probably be more efficient to read blocks backwards and paste them together, but I'm not going to get into that. That actually is a pretty good idea. just reverse the buffer and do a split, the last line becomes the first line and so on. The logic then would be no different than reading from beginning of file. Just need to keep the last half line of the reversed buffer if the wanted one happens to be across buffer boundary. -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: Examples of Quality Technical Writing
That's the most accurate description of Xah's behaviour I've read so far. Jon Perez schrieb: Sherm Pendley wrote: Xah's a pretty well-known troll in these parts. I suppose he thinks someone is going to take the bait and rush to defend the other languages or some such nonsense. Actually, I think Xah often has a point, except he can't seem to express it without resorting to profanity and a controlled manner, thus giving the impression he's a troll. Also, he seems to be blissfully unaware of the concept of netiquette. ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there no compression support for large sized strings in Python?
Did you consider the mmap library? Perhaps it is possible to avoid to hold these big stings in memory. BTW: AFAIK it is not possible in 32bit windows for an ordinary programm to allocate more than 2 GB. That restriction comes from the jurrasic MIPS-Processors, that reserved the upper 2 GB for the OS. HTH, Gerald Claudio Grondi schrieb: Fredrik Lundh [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Claudio Grondi wrote: What started as a simple test if it is better to load uncompressed data directly from the harddisk or load compressed data and uncompress it (Windows XP SP 2, Pentium4 3.0 GHz system with 3 GByte RAM) seems to show that none of the in Python available compression libraries really works for large sized (i.e. 500 MByte) strings. Test the provided code and see yourself. At least on my system: zlib fails to decompress raising a memory error pylzma fails to decompress running endlessly consuming 99% of CPU time bz2 fails to compress running endlessly consuming 99% of CPU time The same works with a 10 MByte string without any problem. So what? Is there no compression support for large sized strings in Python? you're probably measuring windows' memory managment rather than the com- pression libraries themselves (Python delegates all memory allocations 256 bytes to the system). I suggest using incremental (streaming) processing instead; from what I can tell, all three libraries support that. /F Have solved the problem with bz2 compression the way Frederic suggested: fObj = file(r'd:\strSize500MBCompressed.bz2', 'wb') import bz2 objBZ2Compressor = bz2.BZ2Compressor() lstCompressBz2 = [] for indx in range(0, len(strSize500MB), 1048576): lowerIndx = indx upperIndx = indx+1048576 if(upperIndx len(strSize500MB)): upperIndx = len(strSize500MB) lstCompressBz2.append(objBZ2Compressor.compress(strSize500MB[lowerIndx:upper Indx])) #:for lstCompressBz2.append(objBZ2Compressor.flush()) strSize500MBCompressed = ''.join(lstCompressBz2) fObj.write(strSize500MBCompressed) fObj.close() :-) so I suppose, that the decompression problems can also be solved that way, but : This still doesn't for me answer the question what the core of the problem was, how to avoid it and what are the memory request limits which should be considered when working with large strings? Is it actually so, that on other systems than Windows 2000/XP there is no problem with the original code I have provided? Maybe a good reason to go for Linux instead of Windows? Does e.g. Suse or Mandriva Linux have also a memory limit a single Python process can use? Please let me know about your experience. Claudio -- http://mail.python.org/mailman/listinfo/python-list
Re: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packetsto another port
Hi Henko, the proper solution to this problem ist to use on libpcap's python bindings, like for example Billy The Kid. Here are some pointers: http://home.student.utwente.nl/g.v.berg/btk/ http://pycap.sourceforge.net/ http://monkey.org/~dugsong/pypcap/ http://www.tcpdump.org/ (libpcap) HTH Gerald - Original Message - From: Henko Gouws (H) To: python-list@python.org Sent: Tuesday, October 25, 2005 10:26 AM Subject: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packetsto another port Dear reader An application A opens UDP port 162 and listens for incoming packets. We have another application B that wants to receive the same information from UDP port 162 but this application cannot open the port 162 because it is already opened by application A. We want both A and B to receive information from port 162. Does anyone know how to implement such a solution using Python or give relevant advice? Alternatively does anyone know about any postings that involved Ethernet sniffers or Python programs listening to network traffic in promiscuous mode? Thank you regards Henko Gouws (Pr. Eng.) Senior Engineer: Technical Product Development Telkom Development Lab Tel: +27 12 529 7385 Fax: +27 12 548 0065 ~~ This e-mail and its contents are subject to the Telkom SA Limited e-mail legal notice available at http://www.telkom.co.za/TelkomEMailLegalNotice.PDF ~~ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Abstract Methods Abstract Class
Isn't class AbstractBase: def method(self): raise NotImplementedError( abstract method called ) the right thing to do? Gerald - Original Message - From: Andreas Kostyrka [EMAIL PROTECTED] To: Iyer, Prasad C [EMAIL PROTECTED] Cc: python-list@python.org Sent: Thursday, October 20, 2005 8:56 AM Subject: Re: Abstract Methods Abstract Class On Thu, Oct 20, 2005 at 12:05:05PM +0530, Iyer, Prasad C wrote: Do we have something like abstract methods Abstract class. So that my class would just define the method. And the implementation would be defined by somebody else. class AbstractBase: def method(self): raise TypeError(abstract method called) But basically, Python does not have abstract methods, and usually doesn't need them. Andreas -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python GUIs
if you write B = '\x12','\x32' you get an immutable tuple. To get a mutable list use: B = [ '\x12','\x32' ] HTH, Gerald Tuvas schrieb: As a bit more of an update, I have decided to create a list of strings, but am having a problem. To illistrate this in a simple manner. B='\x12','\x32' B[0]='\x12' I cannot get this to work, and I need to get it to work somehow. How can I make it happen? Is there a function that I should use, a special trick, etc? Or is there just no way to make it work? Thanks! -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Do a Python beginners e-mail list exist?
Perhaps irc://irc.freenode.net##python Note the double # This channel is less crowed as the #python channels are. Alessandro Brollo schrieb: Far from a professional programmer, I'm simply a newbie Python user. Two basic questions: 1. I don't want to post banal questions about Python to main Python list. Does a banal Python questions list or a Python beginners list exist? 2. There is somewhere a very patient fellow willing to be my free python tutor by personal e-mailing outside the mail list? . The ideal candidate would be someone, sharing with me some other fields of interest (I'm a middle-aged Italian pathologist, with some dBase III and dBase IV past programming experience, and I like nature and mainly horses). Thanks Alessandro Brollo ___ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: strxfrm works with unicode string ?
How about: import locale s=u'\u00e9' print s locale.setlocale(locale.LC_ALL, '') locale.strxfrm( s.encode( latin-1 ) ) --- HTH, Gerald [EMAIL PROTECTED] schrieb: I am trying to use strxfm with unicode strings, but it does not work. This is what I did: import locale s=u'\u00e9' print s locale.setlocale(locale.LC_ALL, '') 'French_Switzerland.1252' locale.strxfrm(s) Traceback (most recent call last): File pyshell#20, line 1, in -toplevel- locale.strxfrm(s) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 0: ordinal not in range(128) Someone sees what I did wrong ? -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: strxfrm works with unicode string ?
Sali Nicolas :)), please see below for my answers. [EMAIL PROTECTED] schrieb: Gruzi, Gerald ;-) Well, ok, but I don't understand why I should first convert a pure unicode string into a byte string. The encoding ( here, latin-1) seems an arbitrary choice. Well latin-1 is only encoding, about which I know that it works on my xterm and which I can type without spelling errors :) Your solution works, but is it a workaround or the real way to use strxfrm ? It seems a little artificial to me, but perhaps I haven't understood something ... In Python 2.3.4 I had some strange encounters with the locale module, In the end I considered it broken, at least when it came to currency formating. Does this mean that you cannot pass a unicode string to strxfrm ? This works here for my home-grown python 2.4 on Jurrasic Debian Woody: import locale s=u'\u00e9' print s print locale.setlocale(locale.LC_ALL, '') print repr( locale.strxfrm( s.encode( latin-1 ) ) ) print repr( locale.strxfrm( s.encode( utf-8 ) ) ) The output is rather strange: de_DE \x10\x01\x05\x01\x02\x01'@/locale \x0c\x01\x0c\x01\x04\x01'@/locale Another (not so) weird thing happens when I unset LANG. [EMAIL PROTECTED]:~ unset LANG [EMAIL PROTECTED]:~ python2.4 ttt.py Traceback (most recent call last): File ttt.py, line 3, in ? print s UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 0: ordinal not in range(128) Acually it's more weird, that printing works with LANG=de_DE. Back to your question. A quick glance at the C-sources of the _localemodule.c reveals: if (!PyArg_ParseTuple(args, s:strxfrm, s)) So yes, strxfrm does not accept unicode! I am inclined to consider this a bug. A least it is not consistent with strcoll. Strcoll accepts either 2 strings or 2 unicode strings, at least when HAVE_WCSCOLL was defined when python was compiled on your plattform. BTW: Which platform do you use? HTH, Gerald PS: If you have access to irc, you can also ask at irc://irc.freenode.net#python.de. -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT ?] (Pythonic) detection word protected files
Perhaps you can use OpenOffice and it's python UNO Bindings? I only know about their existence, but perhaps this will be a starting point: http://udk.openoffice.org/ HTH, Gerald Gilles Lenfant schrieb: Hi, This is certainly off topic, but as my problem must have a pythonic answer. I'm building an utility that makes a catalog of M$ word files in a giant directory tree. The password protected files must be marked, and I didn't find how to guess which files are password protected and which ones are not. I can't use the COM interface for this because the utility must run on a Linux Samba server. I didn't find anything satisfying in M$ related sites (like msdn) or forums or google. Any hint ? Many thanks by advance. -- Gilles -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Knowing the signature of a function
Use the inspect module like: def tf( a, b, c, *arguments, **keywordArguments ): ... print tf ... import inspect inspect.getargspec( tf ) (['a', 'b', 'c'], 'arguments', 'keywordArguments', None) Xavier Décoret schrieb: Hello, I have the following code: def foo(x,y): pass How can I query the function object foo to know the number of parameters it expects. I can find it is a function using callable(f), I can find some information (listed by dir(foo)) such as the name of the function,etc.. but nowhere I can find the number of arguments. I would like to know wether the function expects one or zero arguments. -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: open file in dir independently of operating system
Hi, it`s import os f = open( os.path.join( dir , 'configuration.smo' ), 'r' ) HTH, Gerald Joerg Schuster schrieb: Hello, I want to open the file 'configuration.smo' that is in directory dir. Yet, I don't know on which os my program is being run. On Unix I would say: f = open(dir + '/configuration.smo', 'r') What is the os-independent version of this line? (I have read the manual of the module os, but I didn't see how to do it.) Jörg Schuster -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: regex over files
Map the file into RAM by using the mmap module. The file's contents than is availabel as a seachable string. HTH, Gerald Robin Becker schrieb: Is there any way to get regexes to work on non-string/unicode objects. I would like to split large files by regex and it seems relatively hard to do so without having the whole file in memory. Even with buffers it seems hard to get regexes to indicate that they failed because of buffer termination and getting a partial match to be resumable seems out of the question. What interface does re actually need for its src objects? -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonic use of properties?
The python rationale is We are all consenting adults.. You shoukd change tens to _tens and ones to _ones, in order to syntacticly mark these attributes as internal. If someone not consenting, wants to mess with your internal representation, it's his fault. HTH, Gerald Marcus Goldfish schrieb: I'd like advice/opinions on when it is appropriate to do attribute/property validation in python. I'm coming from a C#/Java background, where of course tons of wasted code is devoted to property validation. Here is a toy example illustrating my question: # Example: mixing instance attributes with properties. Is it pythonic to # validate property data in setters? Since tens and ones are never # validated, the class can be broken by setting these directly class SillyDecimal(object): A silly class to represent an integer from 0 - 99. def __init__(self, arg=17): if isinstance(arg, tuple): self.tens = arg[0] self.ones = arg[1] else: self.number = arg def getNumber(self): return self.tens*10 + self.ones def setNumber(self, value): if value 0 or value 99: raise ArgumentException(Must in [0, 99]) self.tens = value // 10 self.ones = value % 10 number = property(getNumber, setNumber, None, Complete number, [0-99]) x = SillyDecimal() x.number, x.tens, x.ones# returns (17, 7, 1) Even though tens, ones and number all appear as attributes, only number has its input validated. Since the class is designed to only hold numbers 0 - 99, one can 'break' it by setting self.tens=11, for example. Should tens and ones be made into full-fledged properties and validated? Should number have no validation? Is it more pythonic to encapsulate tightly, or rely on responsible use. Marcus -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: eval function not working how i want it dag namn
How about using the vars builtin? Michael Hoffman schrieb: robcarlton wrote: I've written this function to make a list of all of an objects attributes and methods (not for any reason, I'm just learning) def list_members(obj) l = dir(obj) return map(lambda x : eval('obj.'+x), l) That works fine for me with Python 2.4. This is the best way to do it: def list_members(obj): return [getattr(obj, name) for name in dir(obj)] Although personally I would prefer to have this information in dict form, so i'd use: return dict((name, getattr(obj, name)) for name in dir(obj)) For objects defined in CPython, you can use obj.__dict__, but this is somewhat hacky, and I'd avoid it. -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language for Systems Administrator
Kanthi Kiran Narisetti schrieb: Hi All, Thank You for your suggestionsI request you all to eloborate the Uses(In Practical) for systems administrator.Some of my questions regarding the same follows. 1)Can i build web applications in Python ? If so how. I am planning to build a web application for intranet use which deals with workflow of Internal office communication. Yes, you can. There are far too many options, to be listed here: Here are just 3 pointers: http://www.zope.org/ http://www.cherrypy.org/ http://www.webwareforpython.org/ http://skunkweb.sourceforge.net/ 2)Which is best opensource database to be used with Python ? It's hard to say. It depends on our taste and the type of your application. There is a python standard for a relation DB-API and there are som object relational adapters, like: http://python-dbo.sourceforge.net/ http://sqlobject.org/ http://skunkweb.sourceforge.net/PyDO/ http://dustman.net/andy/python/SQLDict And, of course, there is ZODB the object oriented DB below Zope: http://www.zope.org/Products/ZODB3.3 3)When i write a remote execution script in python is it required that python should be installed in remote system. No. Using xmlrpc the server and may be written in any programming language. xmlrpc is include din the standard libray. Other remote execution systems use CORBA or do things upon their own: http://pyro.sourceforge.net/ It is also possible to package python applications in an executable using: http://starship.python.net/crew/theller/py2exe/ http://starship.python.net/crew/atuining/cx_Freeze/ or the Freeze utility delivered with the python standard distribution. 4)I heard about Perl/CGI and that CGI application done by python too.Is CGI still valid when PHP has taken over the WebApplication Development, Dominating. No it's rather slow, but widley used. There is a mod_python for Apache which is used be some of the web application frameworks mentioned above. Sorry if these questions are out of this group , but answers to these ? will help me a lot. The are perfectly valid. HTH, Gerald -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: variables exist
try: myVariable except NameError: print Not bound else: print Bound If you want to distinguish between the local an the global environment: if globals().has_key( myVariable ): ... versus if locals().has_key( . HTH, Gerald fabian schrieb: how testing if a variable exists in python as isset in php?? thanks -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python backend binding to PAM, NSS or pppd
Hi Heiko, Hi all, I have a PAM-library available that embedds Python. Just tell me if you need it and I will publish it. HTH, Gerald Heiko Wundram schrieb: Hey all! Before I start hacking away, I'm looking for a Python backend binding for libpam or libnss, or a python binding for the pppd plugin mechanism. I'm trying to set up an SQL authentication scheme for virtual user accounts used for mail and PPTP-VPN-access, and I'd love to do the authentication bit in Python. And, yes, I know about pam-mysql and nss-mysql, but both projects are old and unmaintained, and I use Oracle as backend DB anyway. If anybody knows of any project which has implemented a part of this, I'd love to hear about the effort... -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python backend binding to PAM, NSS or pppd
Well, I am actually playing, right now. For http://www.carelix.org I implemented a module that * adds a user to passwd and * authenticates that user given a certificate and some other info on removable media * it creates an encrypted loopback file, that is mounted as the user's home directory utilising Loop-AES and the certficate on the floppy * and it opens an openvpn connection using the same certificate * and, of course, unmounts the loopback file and terminates the vpn on logout. Perhaps this is somewhat more than playing :) cya, Gerald Diez B. Roggisch schrieb: I've been using pyton-pam before. Works as expected - but pam frustrated me a bit, and you gotta run as root for it to work - a thing I didn't want to do. Ok, I just found that you wanted to play from the other side of the fence - never mind my answer. -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a DLL with python?
I think you can, as long as you have a C-Compiler available. I used pyrex to embedd python into a Linux PAM-Module and i used C-Types to embbed Python into a Windows DLL. With hindsight, the pyrex solution was much fatser to develop and less complicated. Pyrex provides an example. Ctypes: http://starship.python.net/crew/theller/ctypes/ Pyrex: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Feel free to ask, if you need a more complex example, than the one, that comes with pyrex. HTH, Gerald Larry Bates schrieb: I don't think you can make a .DLL (but someone else might). Why can't you use a COM server? MS seems to have written some pretty sophisticated software using COM objects. Almost all languages can dispatch a COM object easily. -Larry [EMAIL PROTECTED] wrote: Can I use python to make a regular Windows DLL that will be called from other programs? I know I can use the win32 extensions to make a COM server, but I need a straight DLL. Regards, Phillip Phillip Piper A man's life does not consist in the abundance of his possessions -- GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634 -- http://mail.python.org/mailman/listinfo/python-list