On Tue, 25 Mar 2008 05:42:03 -0700, hellt wrote:
[snip]
> usage = "usage: %prog [options]"
> parser = OptionParser(usage)
> parser.add_option("-f", "--file", dest="filename",
> help="executable filename",
> metavar="FILE")
> parser.add_option("-b"
On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote:
> For the answer I actually want each asterisk substitutes for exactly one
> character.
Played around a bit and found that one:
Python 3.0a3+ (py3k:61352, Mar 12 2008, 12:58:20)
[GCC 4.2.3 20080114 (prerelease) (Debian 4.2.2-7)] on linux2
T
On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote:
> Here's a puzzle for those who think they know Python:
>
> Given that I masked out part of the input, which version(s) of Python
> might give the following output, and what might I have replaced by
> asterisks?
>
a = 1
b =
>>
ds of tracing (apart from debugging, which is rather
unpopular in Python) because you have one *extra* level (the interpreter)
between your machine and your code.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 12 Mar 2008 01:05:06 +0100, Igor V. Rafienko wrote:
> Hi,
>
>
> I was wondering if someone could help me explain this situation:
>
> h[1] >>> import inspect
> h[1] >>> inspect.getmro(ValueError)
> (, ,
> , , 'object'>)
> h[2] >>> try:
> raise ValueError("argh")
> except object:
>
On Sun, 10 Feb 2008 08:46:24 +0100, David Trémouilles wrote:
[snip]
> I tried:
> >>> map(not, boolean_list)
> but it seems that "not" is not a function.
`not` is not a function, indeed. It is a keyword, allowing you to write
``not x`` instead of ``not(x)``.
You can of course write a function t
On Thu, 31 Jan 2008 15:30:09 -0600, Terran Melconian wrote:
> * Is there a way to get headings in docstrings?
>
> I want to create my own sections, like "OVERVIEW", "EXAMPLES",
> "AUTHORS", "BUGS", etc. I can't figure out any way to do this. In
> perldoc, I can easily use =head1, but
On Thu, 31 Jan 2008 20:51:23 +0100, Helmut Jarausch wrote:
> Hi,
>
> the following code works fine
>
> def Helper(M) :
>return 'H>'+M
String concatenation is generally considered unpythonic, better use
string interpolation::
'H> %s' % (M,)
> class A(object):
>def __init__(self,Ms
On Mon, 07 Jan 2008 05:21:42 -0800, Mike wrote:
> I want to do something like the following (let's pretend that this is in
> file 'driver.py'):
>
> #!/bin/env python
>
> import sys
>
> def foo():
> print 'foo'
>
> def bar(arg):
> print 'bar with %r' % arg
>
> def main():
> getattr
On Tue, 11 Dec 2007 12:51:52 -0800, Nishkar Grover wrote:
> I'm trying to replace a built-in exception type and here's a simplified
> example of what I was hoping to do...
>
>
> >>> import exceptions, __builtin__
> >>>
> >>> zeroDivisionError = exceptions.ZeroDivisionError
I don't know why y
On Thu, 13 Dec 2007 22:52:56 +0100, Bruno Desthuilliers wrote:
> flyfree a écrit :
[snip]
>> What is the difference between "y = [3,4]" and "y[0]=3 y[1] =4 "
>
> In the first case, you rebind the local name y to a new list object -
> and since the name is local, rebinding it only affects the loca
On Tue, 11 Dec 2007 08:57:16 -0800, George Sakkis wrote:
> On Dec 10, 11:07 pm, Stargaming <[EMAIL PROTECTED]> wrote:
>> On Mon, 10 Dec 2007 19:27:43 -0800, George Sakkis wrote:
>> > On Dec 10, 2:11 pm, Stargaming <[EMAIL PROTECTED]> wrote:
[snip]
>> >> E
On Mon, 10 Dec 2007 19:27:43 -0800, George Sakkis wrote:
> On Dec 10, 2:11 pm, Stargaming <[EMAIL PROTECTED]> wrote:
>> On Mon, 10 Dec 2007 16:10:16 +0200, Nikos Vergas wrote:
>>
>> [snip]
>>
>> >> Problem: In the dynamic language of your choice, wr
On Mon, 10 Dec 2007 16:54:08 -0800, mosi wrote:
> Python matrices are usually defined with numpy scipy array or similar.
> e.g.
matrix1 = [[1, 2], [3, 4], [5, 6]]
> I would like to have easier way of defining matrices, for example:
matrix = [1, 2; 3, 4; 5, 6]
>
matrix =
> [ 1, 2;
>
On Mon, 10 Dec 2007 16:10:16 +0200, Nikos Vergas wrote:
[snip]
>> Problem: In the dynamic language of your choice, write a short program
>> that will:
>> 1. define a list of the following user ids 42346, 77290, 729 (you can
>> hardcode these, but it should
>> still work with more or less ids)
>>
;>
>> --
>> -- Guilherme H. Polo Goncalves
>
> So acceptable usage (though disgusting :P) would be
>
> while 1: print 'hello'; print 'goodbye'; exec(rm -rf *)
Nope::
exec(rm -rf *)
^
SyntaxError: invalid syntax
Even the syntactically correct ``exec("rm -rf *")`` would make your
computer explode. Should we introduce this as a shortcut to `break`? ;-)
SCNR,
stargaming
--
http://mail.python.org/mailman/listinfo/python-list
ead of */** unpacking would be enough? Like::
superfoo(fooargs=(1,2,3), fookwargs={'foo': 'bar},
objargs=('a', 'b'), objkwargs={'x': 5})
Cheers,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
k since you haven't used x when you try to print it.
You can make this work using the `global` statement::
>>> def foo():
... global x
... print x
... x = 0
...
>>> x = 12345
>>> print x
12345
>>> foo()
12345
>>> print x
0
See more in the `lexical reference about the global statement .
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
invalid)
>>>
>>>
>> i'm not sure what u mean with "the entire structure is invalid"...
>> that's exactly what I got while parsing...
>
> Your structure is correct. Dennis just didn't read all the matching
> parens and brackets prop
Since `script` is a valid module name in your case, referencing
script.py, pydoc uses this file. `scriptpy` is no valid module name and
thus, does not work.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
moving it from a Python programmer's vocabulary
(what essentially wouldn't work so well, I suspect) won't help.
If you're speaking about just the syntax, well okay, this could be
sensible in some unification-focussed vocabulary-minimalistic manner. But
combining the class _statement_ and the type _expression_ would
essentially change class definitions into expressions.
Cheers,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
Table and Initialization Function <http://docs.python.org/ext/
methodTable.html>`_
Cheers,
Stargaming
.. _C++ extensions: http://docs.python.org/ext/cplusplus.html
.. _Embedding in C++: http://docs.python.org/ext/embeddingInCplusplus.html
.. _Extending and embedding: http://docs.python.org/ext/ext.html
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote:
[snip]
>
> Note that there's also the reverse() function that returns a reverse
> iterator over any sequence, so you could also do:
>
> li = list('allo')
> print ''.join(reverse(li))
>
Note this certainly should've been `reversed()`
it
init(__name__)
If you really have to _create_ modules dynamically, follow the advice
given earlier in this thread.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
Adding `__call__` to this implementation should be easy.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
ello, my name is bruno
>>> t.name
getting <__main__.Toto object at 0xb792f66c>.name
'bruno'
>>> t.name = "jon"
setting <__main__.Toto object at 0xb792f66c>.name to jon
>>> t.say_hello()
getting <__main__.Toto object at 0xb792f66c>.name
Hello, my name is jon
Cheers,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
into `construct`_::
>>> from construct import *
>>> foo = BitStruct("foo",
... Octet("spam"), # synonym for BitField("spam", 8)
... BitField("ham", 12),
... BitField("eggs", 12)
... )
&g
t; Thanks.
>
> I wrote a zsh script to do what I wanted, but I'd still like to know how
> to do it in Python.
`subprocess.Popen` has a keyword argument called `stdin` -- what takes
the password, I guess. Assigning `subprocess.PIPE` to it and using
`Popen.communicate` should do the tric
@depends(early_task)
def late_task():
bar()
The wrapping `depends` function could decide whether `early_task` is done
already or not (and invoke it, if neccessary) and finally pass through
the call to `late_task`.
This is just an example how you could use existing syntax to modelize
dependencies, there are other ways I guess.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 01 Oct 2007 10:24:39 -0700, Abandoned wrote:
> Hi..
> dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and
> 3 millions element
>
> I want to combine dict1 and dict2 and i don't want to use FOR because i
> need to performance.
>
> I'm sorry my bed english.
> King rega
ional numbers (but Pi is rational in any
visualization anyways, so FWIW that wouldn't be too much of a blockade).
But where would you put normal integer division then?
Introducing a new type seems best to me.
You could, as well, try to implement this in PyPy. If this would hit the
broad mass
ist")
> links=aia.fetchall()
> linkdict = dict()
> for k,v in links:
> linkdict[k] = v
> print linkdict
Besides using the already pointed out DB adapters, you can easily
transform a list of items into a dictionary with the `dict` constructor::
>>> links = [(1, 5), (2, 5), (3, 10)]
>>> dict(links)
{1: 5, 2: 5, 3: 10}
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 29 Sep 2007 21:20:10 -0700, Googy wrote:
> I am new to python...
>
> The programming language i know well is C Can any one recommend me the
> good ebook for beginners. I have loads of ebooks but i am not able to
> decide which to start with which book. Also i am learning XML so later
> on
on installation directory.
If you don't want to miss IDLE's advantages, `IPython `_ might be interesting for you.
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 21 Sep 2007 23:44:00 -0400, Carl Banks wrote:
> Anyone with me here? (I know the deadline for P3 PEPs has passed; this
> is just talk.)
>
> Not many people are bit-fiddling these days.
Why did we invent the `binary literals`_ (0b101) then?
> One of the main uses of
> bit fields is fl
hing wrong because I don't know how
generators are implemented on the C level but it's more like changing
foo's (or frange's, in your example) return value.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 06 Aug 2007 14:13:51 +, Flavio wrote:
> Hi, I have been playing with set operations lately and came across a
> kind of surprising result given that it is not mentioned in the standard
> Python tutorial:
>
> with python sets, intersections and unions are supposed to be done
> like t
On Mon, 06 Aug 2007 11:13:45 +, Alex Popescu wrote:
> Stargaming <[EMAIL PROTECTED]> wrote in news:46b6df49$0$26165
> [EMAIL PROTECTED]:
>
[snip]
>>
>> You're just unluckily shadowing the name `y` in the local scope of
> your
>> function
argument values between function calls in the first function, but
> doesn't in the second one?
You're just unluckily shadowing the name `y` in the local scope of your
function. Your code snippet could be rewritten as::
def f(x, y=None):
if y is None: my_y = []
else: my_y = y
my_y.append(x)
return my_y
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 04 Aug 2007 08:27:05 +, Rohan wrote:
> Hello,
> I would like my script to run once a week with out any external
> interference.
> More like a timer. Can it be done in python or should some other shell
> scripting be used.
> If anyone knows anything please let me know.
`cron` should be
`dict` methods.
Or you could use the `collections.defaultdict <http://docs.python.org/lib/
defaultdict-objects.html>` type (new in 2.5, too), which I consider most
elegant::
>>> from collections import defaultdict
>>> d2 = defaultdict(lambda:'unknown', d)
>>> d2['name']
'james'
>>> d2['sex']
'unknown'
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 01 Aug 2007 11:28:48 -0500, Chris Mellon wrote:
> On 8/1/07, beginner <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Does anyone know how to put an assertion in list comprehension? I have
>> the following list comprehension, but I want to use an assertion to
>> check the contents of rec_stdl. I e
On Wed, 01 Aug 2007 06:56:36 -0400, Steve Holden wrote:
> Stargaming wrote:
>> On Wed, 01 Aug 2007 05:44:21 +, Michele Simionato wrote:
>>
>>> On Aug 1, 5:53 am, beginner <[EMAIL PROTECTED]> wrote:
>>>> Hi All,
>>>>
>>>> This
On Wed, 01 Aug 2007 05:44:21 +, Michele Simionato wrote:
> On Aug 1, 5:53 am, beginner <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>
>> This is just a very simple question about a python trick.
>>
>> In perl, I can write __END__ in a file and the perl interpreter will
>> ignore everything below tha
On Mon, 30 Jul 2007 11:00:14 -0500, Edward K Ream wrote:
>> The problem is because you are trying to represent a Python
> program as a Python string literal, and doing it incorrectly.
>
> Yes, that is exactly the problem. Thanks to all who replied. Changing
> changing '\n' to '\\n' fixed the pr
On Thu, 26 Jul 2007 15:54:11 -0400, brad wrote:
> How does one make the math module spit out actual values without using
> engineer or scientific notation?
>
> I get this from print math.pow(2,64): 1.84467440737e+19
>
> I want this:
> 18,446,744,073,709,551,616
>
> I'm lazy... I don't want to c
On Thu, 26 Jul 2007 06:41:44 -0700, dittonamed wrote:
> Code pasted below ->
>
> Can anyone out there suggest a way to access the object "p" thats
> started in playAudio() from inside the stopAudio()? I need the object
> reference to use QProcess.kill() on it. The code sample is below. Thanks
On Thu, 26 Jul 2007 12:08:40 +1000, Steven D'Aprano wrote:
> On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote:
>
>> I have tried to prepare a dict and then passing it to the method
>> afterwards:
> d = {'person': 'user', 'from': vorgestern}
> magnolia.bookmarks_find(d)
>> : bookmarks_
g [EMAIL PROTECTED]
See http://docs.python.org/lib/built-in-funcs.html#l2h-16 for classmethod
and http://docs.python.org/tut/node11.html#SECTION001140
for this conventional stuff (paragraph "Often, the first argument ...").
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
't look like an assignment, append it
to this item. You might run into problems with such data:
foo = modern maths
proved that 1 = 1
bar = single
If your dataset always has indendation on subsequent lines, you might use
this. Or if the key's name is always just one word.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 25 Jul 2007 15:46:58 +, beginner wrote:
> On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote:
>> On Wed, 25 Jul 2007 14:50:18 +, beginner wrote:
[snip]
>>
>> > Another question is how do I pass a tuple or list of all the
>> > aurgem
; def foo(a, b, c): print a, b, c
...
>>> t = (1, 2, 3)
>>> foo(*t)
1 2 3
Have a look at the official tutorial, 4.7.4 http://www.python.org/doc/
current/tut/node6.html#SECTION00674
> Thanks,
> cg
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 24 Jul 2007 02:14:38 -0700, mizrandir wrote:
> Can someone tell me why python doesn't crash when I do the following:
>
a=[]
a.append(a)
print a
> [[...]]
print a[0][0][0][0][0][0][0]
> [[...]]
>
> How does python handle this internally? Will it crash or use up lot's o
mulate an xsplit with a regular
> expression, but the same is true for some other string methods too).
Yea, that's a good idea -- fits into the current movement towards
generator'ing everything. But (IIRC) this idea came up earlier and there
has been a patch, too. A quick search at sf.net didn't turn up anything
relevant, tho.
> Bye,
> bearophile
Regards,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
].
phrase = (random.choice(wordlist) for i in xrange(random.randint(1, 5)))
You loose the ability to slice it directly (eg. phrase[3]), though. (See
itertools.islice for a way to do it.)
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
st don't get it...
It does not turn into something. The `sort()` method just works "in
place", i. e. it will mutate the list it has been called with. It
returns None (because there is no other sensible return value).
For you, that means: You don't have to distingui
bdude schrieb:
> Hey, I'm new to python and am looking for the most efficient way to
> see if the contents of a variable is equal to one of many options.
>
> Cheers,
> Bryce R
>
if var in ('-h', '--hello', '-w', '--world'):
pass
Most maintenance-efficient, that is.
--
http://mail.python.o
Steven D'Aprano schrieb:
> On Wed, 11 Jul 2007 08:04:33 +0200, Stargaming wrote:
>
>
>
>>No, I think Bjoern just wanted to point out that all those binary
>>boolean operators already work *perfectly*. You just have to emphasize
>>that you're
ys thought, at least in a Python context, A-B would trigger
A.__sub__(B), while A+(-B) triggers A.__add__(B.__neg__()). A better
choice could be A+~B (A.__add__(B.__invert__())) because it's always
unary (and IMO slightly more visible).
> In response to Stargaming, Steve is making
>
Alan Isaac schrieb:
> Stargaming wrote:
>
>> I think Bjoern just wanted to point out that all those binary boolean
>> operators already work *perfectly*.
>
>
>
>>>> bool(False-True)
>
> True
>
> But reread Steven.
>
> Cheers,
>
Steven D'Aprano wrote:
> On Tue, 10 Jul 2007 23:42:01 +0200, Bjoern Schliessmann wrote:
>
>
>>Alan G Isaac wrote:
>>
>>
>>>My preference would be for the arithmetic operations *,+,-
>>>to be given the standard interpretation for a two element
>>>boolean algebra:
>>>http://en.wikipedia.org/wiki/Tw
d divide the
packets into two categories, "more than 50 lbs" and "less than 50 lbs",
for example. I think binary trees might be interesting here but touching
every object would be way easier.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
t;, the first match will be a good
pointer. Look through the socket manual
(http://docs.python.org/lib/module-socket.html) for timeout.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
dmitrey schrieb:
> hi all,
> I have a
> y = some_func(args)
> statement, and the some_func() produces lots of text output. Can I
> somehow to suppress the one?
> Thx in advance, D.
>
Either rewrite it or pipe sys.stdout to some other file-like object but
your console while running it. The String
Matimus wrote:
> It depends, what are you going to do if there is an exception? If you
> are just going to exit the program, then that works fine. If you are
> going to just skip that file, then the above wont work. If you are
> going to return to some other state in your program, but abort the
> f
t it, it is pretty mutable and might fit your needs perfectly.
Ah, and if you perhaps remove the leading << there, this might be pretty
much implementable by overloading __rshift__ at your koristiti object.
HTH,
Stargaming
.. _pyparsing: http://pyparsing.wikispaces.com/
.. _PLY: http://www.dab
h
...
>>> attrs = {'foo': foo}
>>> cls = type('MyCls', (object,), attrs)
>>> cls().foo(4)
<__main__.MyCls object at 0x009E86D0> 4
Changing ``object`` (the tuple contains all bases) will change the
parent. But, better stick to previous solutions. :)
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
t exposing
> my relation list as simply a list class where all kinds of objects can
> be dumped in, seems too much for me at this point ;-)
>
> Thanks,
> - Jorgen
Consider this: Who should add wrong-typed objects (see Bruno's post for
reasons why you shouldn't care about types, a
uld give /foo/bar\ baz/ham or "/foo/bar baz/ham" (either escaping
the blanks or wrapping the path in quotation marks) a try. I can't
verify it either, just guess from other terminals' behaviour.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
:!python "%"`` into your .vimrc to get the
IDE-feeling (F5 for write+execute) back in.)
Regards,
Stargaming
.. _search for CVS:
http://www.vim.org/scripts/script_search_results.php?keywords=cvs&script_type=&order_by=rating&direction=descending&search=search
--
http://mail.python.org/mailman/listinfo/python-list
> Thanks.
>
IMO, this sounds pretty interesting. Got any sources set up yet?
Thinking of this as something like a "community effort" sounds nice.
Interestedly,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
ivmod(number, base)
>>answer.append(symbols[remainder])
>>return ''.join(reversed(answer))
>>
>>Hope this helps,
>>Michael
>
>
> That's way too complicated... Is there any way to convert it to a one-
> liner so that I can remember it? Mine is quite ugly:
> "".join(str((n/base**i) % base) for i in range(20) if n>=base**i)
> [::-1].zfill(1)
>
Wrote this a few moons ago::
dec2bin = lambda x: (dec2bin(x/2) + str(x%2)) if x else ''
Regards,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
t and the documentation just comes up and there is
> example code and then user comments also.
>
For searching, we got at least pyhelp.cgi_.
HTH,
Stargaming
.. _pyhelp.cgi: http://starship.python.net/crew/theller/pyhelp.cgi
--
http://mail.python.org/mailman/listinfo/python-list
Ron Garret wrote:
> The wsgiref module in Python 2.5 seems to be empty:
>
> [EMAIL PROTECTED]:~/Sites/modpy]$ python
> Python 2.5 (r25:51908, Mar 1 2007, 10:09:05)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>
Alex Martelli schrieb:
> 7stud <[EMAIL PROTECTED]> wrote:
>...
>
>>>.append - easy to measure, too:
>>>
>>>brain:~ alex$ python -mtimeit 'L=range(3); n=23' 'x=L[:]; x.append(n)'
>>>100 loops, best of 3: 1.31 usec per loop
>>>
>>>brain:~ alex$ python -mtimeit 'L=range(3); n=23' 'x=L[:]; x+=
[EMAIL PROTECTED] schrieb:
> Hello!
>
> If I do
>
> import uno
> localContext=uno.getComponentContext()
>
> then localContext is of type
> I guess it's a new type provided by PyUNO extension.
> localContext.__class__ is None
> Is there any way to list all methods of that new type, via Python C
like this feature, you
could try to come up with some patch and a PEP. But not yet.
> In terms of
> syntax, it would not be any worse than the current descriptor objects
> - but it would make lazy evaluation idioms a lot easier to implement.
--
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
t;
``apply()`` is deprecated -- use the asterisk-syntax_ instead.
>>>> dic = {'a': 5, 'loglevel': 10}
>>> def foo(*args, **kwargs):
... print kwargs
...
>>> foo(**dic)
{'a': 5, 'loglevel': 10}
So, your first attempt was close -- just two signs missing. :-)
HTH,
Stargaming
.. _asterisk-sytax:
http://docs.python.org/tut/node6.html#SECTION00674
--
http://mail.python.org/mailman/listinfo/python-list
svn.berlios.de/wsvn/python/spe/trunk/_spe/>`_ and
`Submit a patch <http://developer.berlios.de/patch/?group_id=4161>` are
likely to help you.
Greetings,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
t;http://docs.python.org/ref/yield.html>`_, it is what `xrange
<http://docs.python.org/lib/built-in-funcs.html#l2h-80>`_ uses. You
don't put all numbers into your memory ("precompute them") but behave a
little bit lazy and compute them whenever the user needs the next one. I
expect Google to have lots of example implementations of range as a
generator in python for you. :-)
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
subscriber123 schrieb:
> On Apr 21, 8:58 am, Dustan <[EMAIL PROTECTED]> wrote:
>
>>>From my searches here, there is no equivalent to java's
>>
>>StringTokenizer in python, which seems like a real shame to me.
>>
>>However, str.split() works just as well, except for the fact that it
>>creates it al
self.calculate(crea), what will itself call
SomeClass.calculate(self, crea).)
For further information, consult the python tutorial
http://docs.python.org/tut/node11.html#SECTION001140.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 22, 5:23 pm, Jon Ribbens <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:
> > I don't see any problem with::
>
> > if version_info[0] <= 2 and version_info[1] < 4:
> > raise RuntimeError()
>
> What if the version number is 1.5?
Ah, now I get your pro
On Mar 21, 11:11 pm, Sander Steffann <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Op 21-mrt-2007, om 20:41 heeft [EMAIL PROTECTED] het volgende
> geschreven:
>
>
>
> > On Mar 21, 11:07 am, Jon Ribbens <[EMAIL PROTECTED]> wrote:
> >> In article <[EMAIL P
On Mar 21, 11:07 am, Jon Ribbens <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>, Stargaming wrote:
> > from sys import version_info
> > if version_info[0] < 2 or version_info[1] < 4:
> > raise RuntimeError("You need at least python2.
Karlo Lozovina schrieb:
> Karlo Lozovina <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]:
>
>
>>how would one make a copy of a class object? Let's say I have:
>> class First:
>>name = 'First'
>>
>>And then I write:
>> tmp = First
>
>
> Silly me, posted a question without Googling f
ns but for modules/APIs/builtins whatever and *then* you may raise
an exception pointing the user to the fact that is python version does
not fit your needs.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
gt; Question to c.l.p
> Am Not getting the last part as how you will write a empty string and
> use print not appending blank space in a single line.
I'd guess they think about print "",;print "moo" (print a blank string,
do not skip line, print another one) to preserve the "softspace". As far
as I get your problem, you don't really have to think about it.
> Am not getting
> the (In some cases... ) part of the reference manual section. Please
> help.
>
Use the join-idiom correctly.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
Bert Heymans schrieb:
> On Mar 12, 3:02 am, Alberto Vieira Ferreira Monteiro
> <[EMAIL PROTECTED]> wrote:
>
>>Hi, I am new to Python, how stupid can be the questions I ask?
>>
>>For example, how can I add (mathematically) two tuples?
>>x = (1,2)
>>y = (3,4)
>>How can I get z = (1 + 3, 2 + 4) ?
>>
Donald Fredkin schrieb:
> John wrote:
>
>
>>For my code of radix sort, I need to initialize 256 buckets. My code
>>looks a little clumsy:
>>
>>radix=[[]]
>>for i in range(255):
>> radix.append([])
>>
>>any better code to initalize this list?
>
>
> radix = [[[]]*256][0]
>
>>> x = [[[]]*256]
ly, `total` and `number` seem pretty redundant. You only need
two variables, one containing the targeted number, one the current progress.
By the way, input() is considered pretty evil because the user can enter
arbitrary expressions. It is recommended to use raw_input() (till Python
3.0),
) for x in b]
[0.34338, 0.53221, 0.33452]
I think it should be easy to apply this to your example above.
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
Paul Sijben schrieb:
> All,
>
> in a worker thread setup that communicates via queues is it possible to
> catch exceptions raised by the worker executed, put them in an object
> and send them over the queue to another thread where the exception is
> raised in that scope?
>
> considering that an e
implementing separate class for
> each one is unreal.
You don't have to implement a separate class for *each one*. Use one
class for every attribute, you can reuse it. But perhaps something like
a dict is better for your purposes, anyways.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
e, NotImplemented]))
[NotImplemented, None, NotImplemented, False, False, None, True, True]
Notice that this method works in-place, ie
>>> a = [True, False]
>>> list(randomly(2, a))
[False, False, True, True]
>>> a # a changed!
[False, False, True, True]
This can be changed by creating a copy, though.
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
tContentType
>
> In Java what kind of statement is similar this?
>
> thanks
http://docs.python.org/ref/import.html ("The first form of" and
following, sixth paragraph)
HTH,
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
John Pote schrieb:
> Hi everyone,
>
> Been trying to get the latest version of Stani's Python Editor the last few
> days. But I cannot get any response out of 'pythonide.stani.be'. Anyone know
> what's happened?
>
> Ta much,
>
> John Pote
>
>
http://developer.berlios.de/project/showfiles.p
:print
''.join(__import__('random').choice(__import__('string').letters+'1234567890')
for x in xrange(8)),;n=raw_input()
This is a one-liner (though mail transmission may split it up), no
import statements. If someone can come up with an even smaller version,
feel free to post. :)
-- Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
Stef Mientki schrieb:
> I'm making special versions of existing functions,
> and now I want the help-text of the newly created function to exists of
> 1. an extra line from my new function
> 2. all the help text from the old function
>
> # the old function
> def triang(M,sym=1):
> """The M-poi
W, it's not the 'from future' module, it's just the 'future' (or
'__future__') module. The 'from' clause is a keyword in python used for
imports in the module namespace.
Stargaming
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 111 matches
Mail list logo