Re: can I distribute Microsoft.VC90.CRT files?
On Jun 27, 1:29 pm, "J.O. Aho" wrote: > miamia wrote: > > hello, > > > I find out that my program needs > > Microsoft.VC90.CRT.manifest,msvcm90.dll,msvcp90.dll,msvcr90.dll files > > when I want to run it on win 64bit systems. I find these files in > > some other software. > > Can I simply take it from another software then include it to my > > program folder and distribute it this way? Is it violation or not? > > Read the EULA that comes with Microsoft Visual C++ Redistributable Package. > > -- > > //Aho PLEASE RESPOND WITH AN ANSWER NEXT TIME -- http://mail.python.org/mailman/listinfo/python-list
Re: singleton decorator
[EMAIL PROTECTED] wrote:
> Andre Meyer:
>> What is the preferred pythonic way of implementing singleton elegantly?
>
> Maybe to just use a module.
>
> Bye,
> bearophile
>
Here is some sample code for both singleton classes and named classes
that I use:
> class Singleton(type):
> """
> This class will allow only one instance of a type
> regardless of the initialization arguments.
> """
> def __init__(self, *args, **kwargs):
> """
> This is done when the class is defined.
> """
> type.__init__(self, *args, **kwargs)
> self._instance = None
>
> def __call__(self, *args, **kwargs):
> """
> This is called when the class is instantiated.
> """
> if not self._instance : self._instance =
> type.__call__(self,*args,**kwargs)
> return self._instance
>
> class namedSingleton(type):
> """
> This class will allow a different singleton per initialization
> argument list. This implementation does not take into account
> variations in the keyword args.
> """
> def __init__(self, *args, **kwargs):
> """
> This is executed when the class is first defined.
> """
> type.__init__(self, *args, **kwargs)
> self._instances = {}
>
> def __call__(self, *args, **kwargs):
> """
> This is called when the class is instantiated.
> """
> if not args in self._instances:
> self._instances[args] = type.__call__(self, *args,**kwargs )
> return self._instances[args]
--
http://mail.python.org/mailman/listinfo/python-list
Re: Global Objects...
KraftDiner wrote: > I have a question.. > > myGlobalDictionary = dictionary() > > > class someClass: >def __init__(self): > self.x = 0; >def getValue(self, v) > myGlobalDictionary.getVal(v) > > > myGlobalDictionary doesn't seem to be visible to my someClass methods. > Why? What should I do? > Is it an oversight that you forgot the ':' on the getValue definition? You also forgot to do the return. I say the code should look like: def getValue(self,v) : return myGlobalDictionary[v] I am also confused as to what getVal() does. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: key not found in dictionary
KraftDiner wrote:
> I have a dictionary and sometime the lookup fails...
> it seems to raise an exception when this happens.
> What should I do to fix/catch this problem?
>
> desc = self.numericDict[k][2]
> KeyError: 589824 < This is the error that is being produced,
> because there is no key
> 589824.
>
As stated you can wrap the access in the try - except - else statement,
as in
try:
foo['bar']
except :
# Handle the error.
pass
else :
# We have it, so use it...
print foo['bar']
Or you can use the has_key() and test it first. For example
if foo.has_key('bar'):
print 'we have it'
else :
print 'we don't have bar.'
That'll do it for me.
Chaz.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
t;. The visual > manipulation of components does not preclude making manipulations at > run-time through code also if necessary, and all visual environements > allow the setting of "properties" and "events" at run-time also in the > usual way. > > If one has used Borland's Delphi or C++ Builder IDEs, or Sun's NetBeans > or IBM's Eclipse for Java, or Microsoft's Visual Studio for .Net, one > knows what I mean as far as a visual RAD environment. All of these are > made possible by a common component model which different development > environments can use. > > There's nothing wrong with Python's introspection. In fact Python's > facilities in this area and its support for metadata are stronger than > any of these other languages ! However there is no common component > model which specifies that X is a "property" or Y is an "event" of a > Python class which can be visually manipulated at design-time and > automagically set at run-time, so that any given Python RAD visual > environment will treat a Python class, specified as a component, in > exactly the same way. Also in these other languages, a component is > different from a class in that a component is recognized in a particular > way, often so that the component can interact if necessary with its > container and/or visual site. > > OK, I have proselytized enough . Python is a great language and I > truly love it and its flexibility and ease of programming use. If there > is no impetus to create a component model for re-usable components for > visual RAD environments in Python, that's fine with me. But I thought > someone from the Python development community, given the use of visual > RAD environments for other languages as mentioned above, to create GUI > and large-scale applications, would have considered it. Why not propose something. That is the easiest way to get things moving. Chaz. -- http://mail.python.org/mailman/listinfo/python-list
Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?
Joe Seigh wrote: > Martin v. Löwis wrote: >> You still didn't say what you would suggest to make it thread-safe >> again; most likely, you proposal would be to add locking. If I >> understand Joe's approach correctly, he has a solution that does >> not involve locking (although I don't understand how it works). >> > Sun had applied for a patent on it. You can go to the > uspto search page here http://www.uspto.gov/patft/index.html > and look for > > 20060218561 Code preparation technique employing lock-free pointer > operations > 20060037026 Lightweight reference counting using single-target > synchronization > > Click on the images link on the patent application where the illustrations > are which show the concepts probably better than the text. > > The first one above is actually a continuation patent on three different > techniques. One using double wide compare and swap, one using ROP (Repeat > Offender Problem), a form of PDR, and one using DCAS (compare and swap > of two separate locations) which only exists on MC68020 and MC68030 > processors. > Check out the work in the '80s from the NYU Ultra project. They did a great deal of work on using atomic incr/decr for all sorts of algorithms to get around locking on parallel processors. Chaz. -- http://mail.python.org/mailman/listinfo/python-list
When is a subclass not right?
I was writing some code that used someone else class as a subclass. He wrote me to tell me that using his class as a subclass was incorrect. I am wondering under what conditions, if ever, does a class using a subclass not work. Here is an example. For instance the original class might look like: class A : def __init__(self,arg) : self.foo = arg def bar(self) : return self.foo And I defined a class B1 which looked like: class B1(A); def __init__(self,a1,a2) : self.c = a1 A.__init__(self,ag) He said I should use it this way: class B2: def __init__(self,a1,a2): self.c = a1 self.t = A(a2) def bar(self) : self.t.bar() Other than the obvious difference of B2 having an attribute 't', I can't see any other obvious differences. Is there something I am missing? TIA Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: When is a subclass not right?
Fredrik Lundh wrote: > please don't hit reply to arbitrary messages when you're posting new > messages; it messes up the message threading. > > Chaz Ginger wrote: > >> I was writing some code that used someone else class as a subclass. He >> wrote me to tell me that using his class as a subclass was incorrect. >> I am wondering under what conditions, if ever, does a class using a >> subclass not work. > > your terminology is confused: if you inherit from another class, *your* > class is the subclass, while the class you inherit from is known as a > "base class" or "super class". > > a subclass will share the instance namespace with the base class, which > means, among other things, that you may accidentally override internal > attributes and methods, and thus break the base class. > > and even if it appears to work now, it may break when you upgrade the > base class. or when you end up in a code path that you haven't tested > before. > > > Sorry for the threading screw up. I thought I had just hit the write button. I understand when my class overrides the super class. But that would just be "normal" class related things. I was wondering if there was something more subtle I am missing in Python class handling. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: When is a subclass not right?
Gabriel Genellina wrote: > At Thursday 24/8/2006 16:23, Chaz Ginger wrote: > >> I was writing some code that used someone else class as a subclass. He >> wrote me to tell me that using his class as a subclass was incorrect. I >> am wondering under what conditions, if ever, does a class using a >> subclass not work. >> >> class B1(A); >> def __init__(self,a1,a2) : >> self.c = a1 >> A.__init__(self,ag) >> >> class B2: >> def __init__(self,a1,a2): >> self.c = a1 >> self.t = A(a2) >> >> def bar(self) : >> self.t.bar() >> >> Other than the obvious difference of B2 having an attribute 't', I can't >> see any other obvious differences. Is there something I am missing? > > Look any OO book for the difference between 'inheritance' and > 'delegation'. In short, you should inherit when B 'is an' A (a Car is a > Vehicle), and delegate/compose in other cases (a Car has an Engine; or > more precisely, a Car instance has an Engine instance). > > > Gabriel Genellina > Softlab SRL > > > p5.vert.ukl.yahoo.com uncompressed Thu Aug 24 19:27:05 GMT 2006 > > __ 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 That is merely a logical use of OO after all when would a car and an orange be the same? I was wondering more about the mechanics of Python: when does B1 show different characteristics than B2 (forgoing the obvious simple things, like 't' above). Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Avoiding if..elsif statements
unexpected wrote:
> I have a program where based on a specific value from a dictionary, I
> call a different function. Currently, I've implemented a bunch of
> if..elsif statements to do this, but it's gotten to be over 30 right
> now and has gotten rather tedious. Is there a more efficient way to do
> this?
>
> Code:
>
> value = self.dictionary.get(keyword)[0]
>
> if value == "something":
> somethingClass.func()
> elsif value == "somethingElse":
> somethingElseClass.func()
> elsif value == "anotherthing":
> anotherthingClass.func()
> elsif value == "yetanotherthing":
> yetanotherthingClass.func()
>
> Is it possible to store these function calls in a dictionary so that I
> could just call the dictionary value?
>
Why not do it this way?
foo =
{'something':somethingClass.func,'somethingelse':somethingelseClass.func)
if foo.has_key(value) :
foo[value]()
else :
raise OMG, "%s isn't known" % value
--
http://mail.python.org/mailman/listinfo/python-list
when is a != foo.a?
I am somewhat new to Python (last year). As such I encounter little "gotchas" all the time. I am wondering is someone can explain this to me: If have three simple files: a.py - foo = None def a(b): global foo foo = b b.py -- from a import foo def b(): print foo c.py -- import a from b import b print 'per a.a() ',a.foo a.a(245) print 'expect 245 ', a.foo b() If I run 'python c.py' I get the following printed out: per a.a() None expect 245 245 None That surprised me. If I change b.py to import a def b(): print a.foo I get the following (which is what I expected originally): per a.a() None expect 245 245 245 Can someone explain what is really going on here? TIA, Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: when is a != foo.a?
Duncan Booth wrote: > Chaz Ginger wrote: > >> Can someone explain what is really going on here? > > Think of 'from x import y' as an assignment. Roughly equivalent to: > >y = sys.modules['x'].y > > (except of course you don't have to have imported sys, and it will load the > module 'x' if it hasn't already been imported.) > >> b.py -- >> >> from a import foo > > In other words: > >foo = a.foo > > foo in module b is initialised from a.foo, but it is a separate variable. > So when a.foo is rebound that doesn't affect b.foo. > >> def b(): print foo >> >> c.py -- >> >> import a >> from b import b > > and here: >b = b.b > >> print 'per a.a() ',a.foo >> a.a(245) >> print 'expect 245 ', a.foo >> b() >> > > Thanks, Duncan. It now makes sense. -- http://mail.python.org/mailman/listinfo/python-list
Re: when is a != foo.a?
John Machin wrote: > Chaz Ginger wrote: >> I am somewhat new to Python (last year). As such I encounter little >> "gotchas" all the time. I am wondering is someone can explain this to me: >> >> If have three simple files: >> >> a.py - >> >> foo = None >> def a(b): >> global foo >> foo = b >> >> b.py -- >> >> from a import foo >> def b(): print foo >> >> c.py -- >> >> import a >> from b import b >> >> print 'per a.a() ',a.foo >> a.a(245) >> print 'expect 245 ', a.foo >> b() >> >> >> If I run 'python c.py' I get the following printed out: >> >> >> per a.a() None >> expect 245 245 >> None >> >> >> That surprised me. If I change b.py to >> >> import a >> def b(): print a.foo >> >> I get the following (which is what I expected originally): >> >> >> per a.a() None >> expect 245 245 >> 245 >> >> >> Can someone explain what is really going on here? > > You are, in a very roundabout fashion, effectively executing the > following bindings: > > a.foo = None # done when a is first imported > b.foo = a.foo # done in module b by "from a import foo" > a.foo = 245 > > So b.foo is bound to None, and a.foo is bound to 245. > > Cheers, > John > Thanks John. It is a lot different from the C and C++ world where you can hold a reference to something and use it. That is how I thought about what I was doing and learned it wasn't quite right! lol. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: refering to base classes
glenn wrote: > hi - Im quite new to python, wondering if anyone can help me understand > something about inheritance here. In this trivial example, how could I > modify the voice method of 'dog' to call the base class 'creatures' > voice method from with in it? > > class creature: > def __init__(self): > self.noise="" > def voice(self): > return "voice:" + self.noise > > class dog(creature): > def __init__(self): > self.noise="bark" > > def voice(self): > print "brace your self:" > > thanks > glenn > Try this: class dog(creature): . def voice(self): print "brace your self:" creature.voice(self) This should do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: refering to base classes
Chaz Ginger wrote: > glenn wrote: >> hi - Im quite new to python, wondering if anyone can help me understand >> something about inheritance here. In this trivial example, how could I >> modify the voice method of 'dog' to call the base class 'creatures' >> voice method from with in it? >> >> class creature: >> def __init__(self): >> self.noise="" >> def voice(self): >> return "voice:" + self.noise >> >> class dog(creature): >> def __init__(self): >> self.noise="bark" >> >> def voice(self): >> print "brace your self:" >> >> thanks >> glenn >> > Try this: > > class dog(creature): > . > def voice(self): > print "brace your self:" > creature.voice(self) > > This should do it. I did forget to mention that in 'dog"s' __init__ you had better call creature's __init__. You might make it look like this: def __init__(self): self.noise = 'bark' creature.__init__(self) There is another approach - using Superclass - but I will leave that exercise to the reader. -- http://mail.python.org/mailman/listinfo/python-list
Re: refering to base classes
Jason wrote: > Chaz Ginger wrote: >> Chaz Ginger wrote: >>> glenn wrote: >>>> hi - Im quite new to python, wondering if anyone can help me understand >>>> something about inheritance here. In this trivial example, how could I >>>> modify the voice method of 'dog' to call the base class 'creatures' >>>> voice method from with in it? >>>> >>>> class creature: >>>> def __init__(self): >>>> self.noise="" >>>> def voice(self): >>>> return "voice:" + self.noise >>>> >>>> class dog(creature): >>>> def __init__(self): >>>> self.noise="bark" >>>> >>>> def voice(self): >>>> print "brace your self:" >> I did forget to mention that in 'dog"s' __init__ you had better call >> creature's __init__. You might make it look like this: >> >> def __init__(self): >> self.noise = 'bark' >> creature.__init__(self) >> > > There's a problem with Chaz's __init__() method. Notice that the > creature class's __init__ sets self.noise to the empty string. In this > case, the superclass's __init__() method should be called first: > > class dog(creature): > def __init__(self): > creature.__init__(self) > self.noise = "bark" > def voice(self): > print "brace your self:" > creature.voice(self) > > --Jason > Very trueI was showing him in "spirit only"...lol. Chaz. -- http://mail.python.org/mailman/listinfo/python-list
Re: refering to base classes
glenn wrote: >> Shouldn't that be >> >> beagle = animal.dog() >> >> to create an instance? >> >> We've all done it ... > lol - actually Im confused about this - there seem to be cases where > instantiaing with: > instance=module.classname() > gives me an error, but > instance=module.classname > doesnt - so I got into that habit, except for where I had a constructor > with parameters - except now Im feeling foolish because I cant > replicate the error - which suggests I didnt understand the error > message properly in the first place... arrgh > I guess thats just part of the process of gaining a new language. > > glenn > module.classname and module.classname() are two different things. If you use module.classname() you invoke the __new__ and __init__ methods in the class, and you might get an error from them. On the other hand module.classname will always work, assuming classname really exists in module. What you get back is a sort of reference to the class itself and not an instance of it. -- http://mail.python.org/mailman/listinfo/python-list
Re: refering to base classes
Georg Brandl wrote: > Chaz Ginger wrote: >> glenn wrote: >>>> Shouldn't that be >>>> >>>> beagle = animal.dog() >>>> >>>> to create an instance? >>>> >>>> We've all done it ... >>> lol - actually Im confused about this - there seem to be cases where >>> instantiaing with: >>> instance=module.classname() >>> gives me an error, but >>> instance=module.classname >>> doesnt - so I got into that habit, except for where I had a constructor >>> with parameters - except now Im feeling foolish because I cant >>> replicate the error - which suggests I didnt understand the error >>> message properly in the first place... arrgh >>> I guess thats just part of the process of gaining a new language. >>> >>> glenn >>> >> >> module.classname and module.classname() are two different things. If >> you use module.classname() you invoke the __new__ and __init__ methods >> in the class, and you might get an error from them. >> >> On the other hand module.classname will always work, assuming >> classname really exists in module. What you get back is a sort of >> reference to the class itself and not an instance of it. > > It is not a sort of reference to the class, it is *the class itself*. > > >>> class A: > ... pass > ... > >>> A > > >>> > > Georg A reference by any other name still smells as sweet! lol. -- http://mail.python.org/mailman/listinfo/python-list
Re: Naming conventions
Neil Cerutti wrote: > On 2006-08-30, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On Wed, 30 Aug 2006 14:22:16 +1000, Ben Finney <[EMAIL PROTECTED]> wrote: >>> "glenn" <[EMAIL PROTECTED]> writes: >>> Bruno Desthuilliers wrote: > It might be better to use newstyle classes if you can. Also, the > convention is to use CamelCase for classes names (unless you have > a strong reason to do otherwise). >>> Note that this style is more correctly called TitleCase, since the >> Or StudlyCaps :) > > The first time I saw StudlyCaps I thought it was the ugliest > thing I'd ever seen. Now I use it a lot. I still have trouble > with GVR's preference for HTTPServer over HttpServer. The latter > is, to me, easier to read and write. > Personally I think so long as you are consistent in your coding style, be it httpserver, HttpServer or HTTPServer or any other variation, the reader will soon figure out what it means. If you feel you are being held hostage to capitalized naming conventions you might want to consider having things end in ...Class or ...Instance. At least you would be doing what you say you want to do: making the code more maintainable. Otherwise I say just be consistent and don't let dogma get in the way. All those that remember "Hungarian notation" please stand up! -- http://mail.python.org/mailman/listinfo/python-list
Automatically installing libraries?
Here is a problem I am trying to solve; I am sure there must be an easy way to do it and I just don't know how. I have a rather large application that I am writing. To make it easy for the user to run I have them run a startup.py script. This script will try to load each of the third party libraries the application will need. If it is present, great. If it isn't, I would like to automatically install it. This is the heart of my problem: is there a Python equivalent to PERL's CPAN? Peace, Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: identifying new not inherited methods
Steve Holden wrote: > [EMAIL PROTECTED] wrote: >> Hi, >> >> I am writing a library in which I need to find the names of methods >> which are implemented in a class, rather than inherited from another >> class. To explain more, and to find if there is another way of doing >> it, here is what I want to do: I am defining two classes, say A and B, >> as: >> >> class A(object): >> def list_cmds(self): >> 'implementation needed' >> ? >> def __init__(self): >> ... (rest of class) >> >> class B(A): >> def cmd1(self, args): >> pass >> def cmd2(self, args): >> pass >> >> I need an implementation of list_cmds in A above so that I can get a >> result: >> >> >>>>> b=B() >>>>> b.list_cmds() >> >> ['cmd1','cmd2']#order not important >> >> I will be happy if anybody can point to me any way of doing it, using >> class attributes, metaclasses or otherwise. What I don't want to do is >> modifying class B, which contains just the cmds, if possible. >> >> Many thanks in advance. >> > $ cat test01.py > class A(object): > def list_cmds(self): > """return callable attributes from >subclasses not present in main class.""" > Amethods = [m for m in dir(A) if callable(getattr(A, m))] > return [m for m in dir(self.__class__) > if callable(getattr(self.__class__, m)) >and m not in Amethods] > def __init__(self): > pass > > class B(A): > def cmd1(self, args): > pass > def cmd2(self, args): > pass > > print "A additionals:", A().list_cmds() > print "B additionals:", B().list_cmds() > > > [EMAIL PROTECTED] ~ > $ python test01.py > A additionals: [] > B additionals: ['cmd1', 'cmd2'] > > [EMAIL PROTECTED] ~ > $ > > Hope this helps. > > regards > Steve You don't really want to use dir(A), since this will not pick up all the classes that make up A. Don't you want to use the MRO instead? Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: identifying new not inherited methods
Steve Holden wrote: > Chaz Ginger wrote: >> Steve Holden wrote: >> >>> [EMAIL PROTECTED] wrote: >>> >>>> Hi, >>>> >>>> I am writing a library in which I need to find the names of methods >>>> which are implemented in a class, rather than inherited from another >>>> class. [...] >> >> >> You don't really want to use dir(A), since this will not pick up all >> the classes that make up A. Don't you want to use the MRO instead? >> > Tell me, what won't appear in the dir() of A that *will* appear in the > dir() of a subclass of A? Seems to me you're trying to overcomplicate > things. > > regards > Steve You are right...I just never did a dir(class) before, instead relying on using the MRO to do the searching. dir(class) is certainly a lot simpler! Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Best way to handle large lists?
I have a system that has a few lists that are very large (thousands or tens of thousands of entries) and some that are rather small. Many times I have to produce the difference between a large list and a small one, without destroying the integrity of either list. I was wondering if anyone has any recommendations on how to do this and keep performance high? Is there a better way than [ i for i in bigList if i not in smallList ] Thanks. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
I've done that and decided that Python's 'list comprehension' isn't a way to go. I was hoping that perhaps someone had some experience with some C or C++ library that has a Python interface that would make a difference. Chaz Sybren Stuvel wrote: > Bill Williams enlightened us with: >> I don't know enough about Python internals, but the suggested >> solutions all seem to involve scanning bigList. Can this presumably >> linear operation be avoided by using dict or similar to find all >> occurrences of smallist items in biglist and then deleting those >> occurrences? > > And how would that beat O(n)? Every element of bigList has to be > scanned at one point, either to compare it to every earlier element in > bigList and eliminate it, or to compare it to every element in > smallList. > > Run benchmarks on the suggestions, and see which is fastest for > yourself. > > Sybren -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Paul Rubin wrote: > Sybren Stuvel <[EMAIL PROTECTED]> writes: >>> I don't know enough about Python internals, but the suggested >>> solutions all seem to involve scanning bigList. Can this presumably >>> linear operation be avoided by using dict or similar to find all >>> occurrences of smallist items in biglist and then deleting those >>> occurrences? >> And how would that beat O(n)? Every element of bigList has to be >> scanned at one point, either to compare it to every earlier element in >> bigList and eliminate it, or to compare it to every element in >> smallList. > > Maybe the application should use sets instead of lists for these > collections. What would sets do for me over lists? Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Larry Bates wrote: > Chaz Ginger wrote: >> I have a system that has a few lists that are very large (thousands or >> tens of thousands of entries) and some that are rather small. Many times >> I have to produce the difference between a large list and a small one, >> without destroying the integrity of either list. I was wondering if >> anyone has any recommendations on how to do this and keep performance >> high? Is there a better way than >> >> [ i for i in bigList if i not in smallList ] >> >> Thanks. >> Chaz > > > IMHO the only way to speed things up is to know more about the > actual data in the lists (e.g are the elements unique, can they > be sorted, etc) and take advantage of all that information to > come up with a "faster" algorithm. If they are unique, sets > might be a good choice. If they are sorted, bisect module > might help. The specifics about the list(s) may yield a faster > method. > > -Larry Each item in the list is a fully qualified domain name, e.g. foo.bar.com. The order in the list has no importance. That is about all there is to the list other than to say the number of items in a list can top out about 10,000. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
Jeremy Sanders wrote: > Jeremy Sanders wrote: > >> Chaz Ginger wrote: >> >>> What would sets do for me over lists? >> It's faster to tell whether something is in a set or dict than in a list >> (for some minimum size). > > As a footnote, this program > > import random > num = 10 > > a = set( range(num) ) > for i in range(10): > x = random.randint(0, num-1) in a > > completes in less than a second, whereas > > import random > num = 10 > > a = range(num) > for i in range(10): > x = random.randint(0, num-1) in a > > takes a long time on my computer. > > Jeremy > Thanks Jeremy. I am in the process of converting my stuff to use sets! I wouldn't have thought it would have made that big a deal! I guess it is live and learn. Peace, Chaz -- http://mail.python.org/mailman/listinfo/python-list
Packaging up a Python/Twisted Matrix application...
I have a rather large Python/Twisted Matrix application that will be run on Windows, Linux and perhaps Macs. I was wondering if there are any tools that can be used to create an installer that will bring in Python, Twisted Matrix, my application libraries and anything else I need? I have tried using ezsetup with no luck (it seems not everything can be installed with it). I was hoping to find something as nice (and complete) as Perl's CPAN but can't seem to find anything. Does anyone have any recommendations? Peace, Chaz. -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads, signals and sockets (on UNIX)
geoffbache wrote: >> Twisted *should* be able to do this, as it uses non-blocking IO. >> >> http://twistedmatrix.com/trac/ > > Thanks for the tip. I'll take a look if nobody has any better > suggestions. > > It still seems to me that what I'm trying to do is essentially quite > simple, and shouldn't require > as large a tool as Twisted to fix it. Isn't Twisted basically for web > applications? > > Geoff > You could probably use the Asyncore stuff to do it as well (with a lot less stuff). C. -- http://mail.python.org/mailman/listinfo/python-list
XMLRPC and SSL
I have a web service that I built and it requires using SSL. I have found a few examples of clients using SSL but none that allow me to change the client's certificate or the chain of certificates the client will use to authenticate the server. I was wondering if anyone knows of a good example of this? TIA, Chaz. -- http://mail.python.org/mailman/listinfo/python-list
Minimal Linux system to run Python
I have a need for the minimal Linux system to run Python. Basically I want the system to boot up and instead of starting up Init/etc. I would love it to run python (and a python script I have written). Before embarking on doing it myself I was wondering if anyone knew of just such a system? Peace, Chaz -- http://mail.python.org/mailman/listinfo/python-list
Authenticating clients and servers
I am writing a distributed server system using Python. I need to support authentication and was wondering what approaches are available under Python and what are the best practices. Thanks in advance Chaz -- http://mail.python.org/mailman/listinfo/python-list
Re: Authenticating clients and servers
Thomas Krüger wrote: > Chaz Ginger schrieb: >> I am writing a distributed server system using Python. I need to support >> authentication and was wondering what approaches are available under >> Python and what are the best practices. > > Well, there are many ways of client authentication. To narrow it down it > would be nice if your tell us something about the protocol you are > planning to use. > > Many protocols support an additional SSL/TLS-Layers (e.g. HTTP -> > HTTPS). There you can use SSL certificate authentication. It may > berequired to set up a small CA, but done right it is pretty secure. > > Thomas > I am leaning toward using Kerberos via GSS, but I am willing to listen to other ideas. I've played around with TLS but the problem is that updating the .PEM files can be a pain. I was also thinking about X509, and was wondering if anyone has experience with it. Chaz -- http://mail.python.org/mailman/listinfo/python-list
Using X509 (and TLSlite) authentication
I have been looking for a server application as an example of how to use TLSLite or PyOpenSSL X509 certificates for authentication. Does any one have a pointer or two? Peace, Chaz -- http://mail.python.org/mailman/listinfo/python-list
