Re: 2**2**2**2**2 wrong? Bug?

2007-07-11 Thread Evan Klitzke
gt; | 9 > | 9 > | 9 > > Sorry, couldn't resist. But you can append ! (i.e. factorial) indefinitely without adding any digits to make the number arbitrarily large ;-) -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create new files?

2007-07-12 Thread Evan Klitzke
ere is an implementation in mxtools, however). -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast powerset function

2007-07-12 Thread Evan Klitzke
pset = set() for num_tokens in xrange(1, len(s)): for combo in get_combinations(s, num_tokens): pset.add(combo) # These two are special cases pset.add(s) pset.add(tuple()) return pset if __name__ == '__main__': print powerset((1, 2, 3, 4)) -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast powerset function

2007-07-12 Thread Evan Klitzke
On 7/12/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > On 7/12/07, Arash Arfaee <[EMAIL PROTECTED]> wrote: > > I need a powerset generator function. It's really slow with recursion. Does > > anybody have any idea or code(!!) to do it in an acceptable time? > >

Re: Fast powerset function

2007-07-13 Thread Evan Klitzke
om a coworker: s = range(18) result = [] l = len(s) for i in range(2**l): n = i x = [] for j in range(l): if n & 1: x.append(s[j]) n >>= 1 result.append(x) print result -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Evan Klitzke
inline is a keyword in C since C99. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Semantics of file.close()

2007-07-17 Thread Evan Klitzke
try to close a file that isn't open. In Python you don't even have to worry about that -- if you close a regular file object more than once no exception will be thrown, _unless_ you are using os.close(), which mimics the C behavior. If you are out of space, in C you will get

Re: Semantics of file.close()

2007-07-17 Thread Evan Klitzke
On 7/17/07, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > "Evan Klitzke" <[EMAIL PROTECTED]> writes: > > > You should take a look at the man pages for close(2) and write(2) (not > > fclose). Generally you will only get an error in C if you try to close > &g

Re: Newbie: freebsd admin scripting

2007-07-18 Thread Evan Klitzke
t come up. If you're diligent with this you can start writing your own sysadmin python toolkit to make your job a lot easier. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Code objects

2007-07-23 Thread Evan Klitzke
an object/function foo components = [cc[1] for cc in inspect.getmembers(foo,\ inspect.iscode)] -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: python-fam documentation.

2007-07-25 Thread Evan Klitzke
On 7/25/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > On 7/23/07, Shriphani <[EMAIL PROTECTED]> wrote: > > Folks, > > I am trying to create an app which stares at a file and when the file > > is altered, the script joins a channel on freenode and reports that >

Re: python-fam documentation.

2007-07-25 Thread Evan Klitzke
rtunately i have been unable > to find documentation for it. Can someone please help me ? > Thanks, > Shriphani Palakodety. If you're running a newish version of Linux; this module has fairly complete documentation. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: making a variable available in a function from decorator

2007-07-30 Thread Evan Klitzke
f course, it would generally be better to write your own class for this sort of thing, so that you can set the variable in the instance scope. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

calling superclass __init__ when superclass is object

2007-08-01 Thread Evan Klitzke
Hi list, I was reading this article: http://fuhm.net/super-harmful/ and didn't understand the comment about calling super(Foo, self).__init__() when Foo inherits only from object. Can someone on the list elaborate more on why one should do this? -- Evan Klitzke <[EMAIL PROTECTED]&g

Re: access the name of my method inside it

2007-08-01 Thread Evan Klitzke
; Thanks. > james I would suggest instead setting an attribute on the function object via a decorator, and then have your mod_python handler check for the presence of that attribute on the function that is being called, rather than doing a DB lookup. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: calling superclass __init__ when superclass is object

2007-08-01 Thread Evan Klitzke
On 8/1/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > Hi list, > > I was reading this article: http://fuhm.net/super-harmful/ and didn't > understand the comment about calling super(Foo, self).__init__() when > Foo inherits only from object. Can someone on the list e

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Evan Klitzke
print 'bar' def my_and(lh, rh): return a and b Then my_and(a(), b()) will evaluate both a and b and print both foo and bar even though a() is False. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Best programs written completly in Python

2007-08-05 Thread Evan Klitzke
drian code review system is written in Python and looks really amazing. I just wish I could try it out :-) -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Seek the one billionth line in a file containing 3 billion lines.

2007-08-07 Thread Evan Klitzke
split the log file into smaller chunks (split can split by line amounts), but since that still has to scan the file it will will be IO bound. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Misleading wikipedia article on Python 3?

2007-08-08 Thread Evan Klitzke
o stderr. As a function, you can convert print wholesale to another logging function, or wrap it transparently like this to provide additional logging functionality. What do you find wrong with this sort of "monkeypatching"? -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Assignments and Variable Substitution

2007-08-13 Thread Evan Klitzke
ng a loop. You can't assign a variable whose name is 123, but you can do this sort of thing with setattr. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: using super() to call two parent classes __init__() method

2007-08-17 Thread Evan Klitzke
because the super call doesn't really call the parent class' method, it actually calls the next method in the MRO. The MRO in this case will be Base -> Parent1 -> Parent2 -> object. You can read the details of Python's MRO here http://www.python.org/download/releases/2.3/mro/

Re: Retrieving a variable's name.

2007-08-20 Thread Evan Klitzke
for key, value in globals().iteritems(): if value is arg: d[key] = value break return d Note that this returns a dictionary, rather than a string, but this is trivial to modify. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving a variable's name.

2007-08-20 Thread Evan Klitzke
On 8/20/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > On 8/20/07, rodrigo <[EMAIL PROTECTED]> wrote: > > How would I go about retrieving a variable's name (not its value)? I > > want to write a function that, given a list of variables, returns a > > string w

Re: Extracting the traceback

2007-08-21 Thread Evan Klitzke
o a string for some other purpose (e.g. logging, email notifications) I believe that you must use a StringIO object. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Extracting the traceback

2007-08-21 Thread Evan Klitzke
On 8/21/07, codesite-noreply <[EMAIL PROTECTED]> wrote: > On 22 Ago, 02:09, "Evan Klitzke" <[EMAIL PROTECTED]> wrote: > > On 8/21/07, billiejoex <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi there, > > > I'm f

Re: Co-developers wanted: document markup language

2007-08-24 Thread Evan Klitzke
sions of documents, or do you plan to have a real PDF/Postscript backend? -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Co-developers wanted: document markup language

2007-08-24 Thread Evan Klitzke
p language. Are there any plans on adding provisions for layout and positioning? The difficulty of learning advanced layout has been one of my major frustrations with LaTeX (I'm referring to LaTeX's weird box system, I'm not sure exactly what the proper terminology for it is). --

Re: Check for dict key existence, and modify it in one step.

2007-08-28 Thread Evan Klitzke
CountingDictionary(dict): def increment(self, key, delta=1): self[key] = self.get(key, 0) + delta Hope this helps! -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Will Python 3.0 remove the global interpreter lock (GIL)

2007-09-02 Thread Evan Klitzke
;re running at about half the speed of CPython, and have a preliminary JIT that can translate certain integer operations into assembly, and will be expanded upon in future releases. If you're looking for a progressive alternative to CPython, I'd keep an eye on that project ;-) -- Evan Kl

Re: Why 'class spam(object)' instead of class spam(Object)' ?

2007-09-06 Thread Evan Klitzke
gt; Type 'type'? What is that supposed to mean? I'm not 100% sure how new style classes work, but my understanding is that while normally we refer to objects as instances of classes, classes are really instances of type objects! Types are treated specially (IIRC, types are

Re: 2 daemons write to a single file /w python file IO

2007-09-11 Thread Evan Klitzke
esses with the file descriptor open and writable at once. > I also wonder if one side locked the file, what happens if the other side > try to open this locked file? raise error? so i also need to write a loop to > wait for the file to release locking? The flock call will block if the file is already locked. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating HTML

2007-09-12 Thread Evan Klitzke
vy web application framework. See http://www.cheetahtemplate.org/ -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating HTML

2007-09-12 Thread Evan Klitzke
On Wed, 2007-09-12 at 09:54 +0200, Bruno Desthuilliers wrote: > Evan Klitzke a écrit : > > It's not applicable for everything, but if you're planning on using > > Python to generate web pages you should really be using Cheetah > > templates. Very simple to use te

Re: can Python be useful as functional?

2007-09-17 Thread Evan Klitzke
Haskell!), but I wouldn't try to write functional code in Python -- the language isn't optimized for this type of code, and the syntax it provides isn't very elegant, compared to other functional languages. If you want to write functional code, use a real functional language! -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: super() doesn't get superclass

2007-09-17 Thread Evan Klitzke
ss methods by passing in self (i.e. the old-style way of doing it), and in fact using super is far more flexible. There's no way to magically know when to call the superclass' method, and even if you knew when, there's no way to magically know when it needs to be called. If you're using multiple inheritance, and you're _not_ using super everywhere, then your code is broken anyway. Use super correctly in your own code, and you don't need to worry about other people using it incorrectly. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Preemption in python

2007-09-23 Thread Evan Klitzke
itch threads every 100 bytecode instructions (http://docs.python.org/api/threads.html). Note that if you are synchronizing around a lock, you may need to sleep before trying to reacquire the the lock to completely exit the critical section. A good overview of this (and the Python threading m

Re: comparing elements of a list with a string

2007-09-25 Thread Evan Klitzke
're using the string.find method to search for the file, I'd replace it with "if file in element", which is a bit more idiomatic. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: python project ideas

2007-10-25 Thread Evan Klitzke
age is sent out. You'd probably write this as an extension to Mako/Cheetah (and possibly extend something like mod_python/mod_wsgi, don't know whether these support chunked output or not), but you could also write your own templating engine for this. -- Evan Klitzke <[EMAIL PROTE

Re: modifying __class__

2007-10-26 Thread Evan Klitzke
s inherit from the metaclass rather than object, but I don't really have any experience doing this. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

marshal vs pickle

2007-10-30 Thread Evan Klitzke
hat enough? -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Guaranteeing an n-byte data type?

2009-01-09 Thread Evan Jones
hon as a long integer - who knows how that data is actually represented in memory behind the scenes!) Perhaps since I'm trying to perform low-level operations, Python is simply the wrong tool for this job. However, I'd very much like to write this implementation in Python for sak

Re: Guaranteeing an n-byte data type?

2009-01-09 Thread Evan Jones
ut and endianness. > > Thank you, everyone. struct appears to be exactly what I want; combined with MRAB's insight into how socket.send() works, I feel I should be able to code this in at around 25% the length of equivalent C code. Cheers, Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: PyGame font issues

2009-04-28 Thread Evan Kroske
but if you're going to have more than one question about PyGame, it would be a good idea to join the official PyGame mailing list. Regards, Evan Kroske -- http://mail.python.org/mailman/listinfo/python-list

Python installation challenge

2009-04-29 Thread Evan Kroske
have much experience with Linux and the terminal. I'm using Intrepid Ibex 64 bit on a PC. Attached is a zip file containing the output of ./configure and make. If you need any more info, just tell me how to get it for you. Thanks for helping. Best regards, Evan Kroske -- http://mail.python.org/mailman/listinfo/python-list

Python 2.6 worth the hassle?

2009-05-06 Thread Evan Kroske
ogspot.com/2009/05/jaunty-jackalope-released-vista-all.html). Best regards, Evan Kroske Undecided Python Student -- http://mail.python.org/mailman/listinfo/python-list

Odd list behavior

2009-05-13 Thread Evan Kroske
-long list: key = string.split()[:1] Success! Finally, the operation works perfectly if I initialize the list beforehand: list = string.split() key = list[0] Success! Why does this happen? -- | Evan Kroske Welcome2Obscurity.Blogspot.com <http://welcome2obscurity.blogspot.com> Glory is fleetin

Re: Your Favorite Python Book

2009-05-15 Thread Evan Kroske
ent. I don't have a recommendation; that's the only Python book I own. -- Evan Kroske Welcome2Obscurity.Blogspot.com <http://welcome2obscurity.blogspot.com> Glory is fleeting, but obscurity is forever. — some French guy -- http://mail.python.org/mailman/listinfo/python-list

Re: Java Developer with Chordiant, Hyderabad

2010-06-10 Thread Evan Plaice
You do realize that this is a python and not Java usenet group right? You'd be better off checking out comp.lang.python -- http://mail.python.org/mailman/listinfo/python-list

Re: GUIs - A Modest Proposal

2010-06-10 Thread Evan Plaice
This is my first foray into usenet and f*** the signal to crap ratio in here is ridiculous. I can't believe that there are 150+ answers and little or no useful information yet I was wondering the same thing since the subject of cross platform GUI dev makes me cringe. I was wondering if there was a

Delegate attribute requests to object

2009-08-13 Thread Evan Kroske
objectA = Decorator() > objectB = Decorated() > assert objectA.oldFunction() == objectB.oldFunction() # No error > Is it possible (without inheritance)? -- Evan Kroske http://welcome2obscurity.blogspot.com/ The code, comments, and challenges of a novice software developer desperate for attention. -- http://mail.python.org/mailman/listinfo/python-list

Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
ething up by passing in the variable that i want to change as a *string* and looking up that string in a dictionary somewhere, but I think what I need is the locals () dictionary of the calling function, and I'm not sure how to get that. Thanks, Evan Driscoll -- http://mail.python.org/mailman/listinfo/python-list

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
On Aug 25, 2:33 pm, Evan Driscoll wrote: > I want to make a context manager that will temporarily change the > value of a variable within the scope of a 'with' that uses it. This is > inspired by a C++ RAII object I've used in a few projects. Ideally, > what I want is s

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
On Aug 25, 3:07 pm, Evan Driscoll wrote: > Okay, so I think I actually got this with some consultation with a > friend. Critiques? This is wrong; it's not quite working right. It does with the example I posted, but not in a more thorough test. I'm still ignoring the "you c

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
rint "20:", x print "7:", y print "5:", x test() print "5:", x How does that look? And thanks for making me think about what I'm doing. :-) Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-25 Thread Evan Driscoll
On Aug 25, 3:47 pm, Evan Driscoll wrote: > So here is my simplified version that only works for globals: So I think this works if (1) you only use changed_value in the same module as it's defined in (otherwise it picks up the globals from the module it's defined in, which is almost

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-26 Thread Evan Driscoll
tty stupid... though in my defense, I'm new at more that trivial Python coding and don't have the Python scoping rules and such ingrained in my mind yet. :-) Evan -- http://mail.python.org/mailman/listinfo/python-list

Is this PEP viable?

2017-07-17 Thread Evan Adler
I would like to submit the following proposal. In the logging module, I would like handlers (like file handlers and stream handlers) to have a field for exc_info printing. This way, a call to logger.exception() will write the stack trace to the handlers with this flag set, and only print the messag

Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
According to the description of Python's method resolution order (mro) (https://www.python.org/download/releases/2.3/mro/), a.k.a. C3 linearization (see Wikipedia), the algorithm can be described as follows: "the linearization of C is the sum of C plus the merge of the linearizations of the parent

Re: Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
I don't see how, since the L(B*)'s are listed in order in the argument list: L(B1), L(B2), ..., and each L(B*) starts with B*: L(B1) = , L(B2) = , ... Could you please give a counter-example? On Tue, Aug 15, 2017 at 9:44 PM, Ian Kelly wrote: > > On Tue, Aug 15, 2017 at 9:56 AM,

Re: Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
Thanks! On Tue, Aug 15, 2017 at 10:41 PM, Ian Kelly wrote: > > On Tue, Aug 15, 2017 at 12:57 PM, Evan Aad wrote: > > I don't see how, since the L(B*)'s are listed in order in the argument > > list: L(B1), L(B2), ..., and each L(B*) starts with B*: L(B1) = > ..

<    1   2   3