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
ere is an implementation in mxtools, however).
--
Evan Klitzke <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
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
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?
> >
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
inline is a keyword in C since C99.
--
Evan Klitzke <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
>
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
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
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
; 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
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
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
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
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
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
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
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/
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
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
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
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
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
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).
--
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 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
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
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
vy web
application framework. See http://www.cheetahtemplate.org/
--
Evan Klitzke <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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 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
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
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
hat enough?
--
Evan Klitzke <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
-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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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) = > ..
201 - 261 of 261 matches
Mail list logo