Re: keep a list of read and unread items

2006-08-13 Thread Stargaming
Ant schrieb: > a wrote: > > >>i m building an rss reader and i want you suggestions for datastructure >>for keeping read and unread list for each use >>i m assuming it will be very sparse > > > A dictionary for each site seems to be the obvious choice, mapping the > article ID to True or False.

Re: yet another noob question

2006-08-13 Thread Stargaming
is? So, basically i'm looking for a > list of all combinations of 1-5 in a 5 digit unique number. Also, when > I send the list to print there can't be any duplicates of the combos. > > > Thanks, > > Mike > Generally, it is range(1, 5) S

Re: yet another noob question

2006-08-13 Thread Stargaming
Stargaming schrieb: > mike_wilson1333 schrieb: > >> I would like to generate every unique combination of numbers 1-5 in a 5 >> digit number and follow each combo with a newline. So i'm looking at >> generating combinations such as: (12345) , (12235), (4) and so

Re: yet another noob question

2006-08-14 Thread Stargaming
Jason Nordwick schrieb: > Or without filter: > > from operator import add > def pr(x): print x > def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) > x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) > [...] reduce(add, list) is the same as sum(list) and is only half as fast as su

Re: yet another noob question

2006-08-14 Thread Stargaming
Jason Nordwick wrote: > > [EMAIL PROTECTED] wrote: > >> Jason Nordwick: >> >>> Stargaming wrote: >>> >>>> Also note that reduce will be removed in Python 3000. >>> >>> What will replace it? >> >> >> Nothing

Re: yet another noob question

2006-08-14 Thread starGaming
Jason Nordwick wrote: > *mouth agape* > > Wow. That really sucks. I make extensive use of reduce. It seems to run more > than twice as fast as a for loop. > > >>> t = Timer('bino.reduceadd(bino.bits)', 'import bino') > >>> s = Timer('bino.loopadd(bino.bits)', 'import bino') > >>> t.timeit(10) > 1

Re: List match

2006-08-17 Thread Stargaming
x27;, 'apple', 'orange', 'pear', 'banana'] > Why using Set two times, when you can do it with one call? >>> list(set(one + two)) According to my benchmarks, this was five times faster than calling it twice and use |. There are also a few more good approaches uniquifying lists at http://www.peterbe.com/plog/uniqifiers-benchmark Regards, Stargaming -- http://mail.python.org/mailman/listinfo/python-list

Re: Permission Denied

2006-08-20 Thread Stargaming
e). You can use ./yourpythonscript in this case. Another possibility is using `python script.py` to let the python interpreter do the work directly. The most "advanced" way would be expanding PATH with /home/youraccount/python/learning (use PATH=$PATH:/path/here..). Choose the one you're most comfortable with. :-) Sincerely, Stargaming -- -- http://mail.python.org/mailman/listinfo/python-list

Re: forwarding *arg parameter

2006-11-05 Thread Stargaming
Tuomas schrieb: > >>> def g(*arg): > ... return arg > ... > >>> g('foo', 'bar') > ('foo', 'bar') > >>> # seems reasonable > ... > >>> g(g('foo', 'bar')) > (('foo', 'bar'),) > >>> # not so good, what g should return to get rid of the outer tuple > > TV Use the following then: >>> g(*g('fo

Re: forwarding *arg parameter

2006-11-05 Thread Stargaming
Tuomas schrieb: > Tuomas wrote: > >> def g(*arg): >> return arg >> >> def f(*arg): >> return g(arg) >> >> How can g know if it is called directly with (('foo', 'bar'),) or via >> f with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if >> I know the number of arguments, but

Re: Changing the names of python keywords and functions

2007-06-22 Thread Stargaming
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

Re: try/except with multiple files

2007-06-22 Thread Stargaming
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

Re: howto run a function w/o text output?

2007-06-22 Thread Stargaming
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

Re: newbie-question

2007-07-03 Thread Stargaming
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

Re: accessing an object instance by only having one of its attribute values

2007-07-08 Thread Stargaming
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

Re: bool behavior in Python 3000?

2007-07-10 Thread Stargaming
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

Re: bool behavior in Python 3000?

2007-07-11 Thread Stargaming
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, >

Re: bool behavior in Python 3000?

2007-07-11 Thread Stargaming
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 >

Re: bool behavior in Python 3000?

2007-07-12 Thread Stargaming
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

Re: Most efficient way to evaluate the contents of a variable.

2007-07-12 Thread Stargaming
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

Re: NoneType object not iterable

2007-07-13 Thread Stargaming
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

Re: Itertools question: how to call a function n times?

2007-07-19 Thread Stargaming
]. 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

Re: Suggestion: str.itersplit()

2007-04-22 Thread Stargaming
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

Re: Generalized range

2007-04-26 Thread Stargaming
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

Re: SPE

2007-04-26 Thread Stargaming
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

Re: Having problems accepting parameters to a function

2007-05-01 Thread Stargaming
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

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Stargaming
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

Re: How do I get type methods?

2007-05-03 Thread Stargaming
[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

Re: which is more pythonic/faster append or +=[]

2007-05-10 Thread Stargaming
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+=

Re: Is wsgi ready for prime time?

2007-05-17 Thread Stargaming
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. >

Re: omissions in python docs?

2007-05-17 Thread Stargaming
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

Re: How to convert a number to binary?

2007-05-17 Thread Stargaming
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

Re: A new project.

2007-05-17 Thread Stargaming
> 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

Re: alternative to eclipse [ python ide AND cvs ]

2007-05-17 Thread Stargaming
:!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

Re: Installing Python in a path that contains a blank

2007-05-21 Thread Stargaming
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

Re: [Fwd: Re: managed lists?]

2007-05-21 Thread Stargaming
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

Re: How to set a class inheritance at instance creation?

2007-05-29 Thread Stargaming
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

Re: From D

2007-07-24 Thread Stargaming
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

Re: Recursive lists

2007-07-24 Thread Stargaming
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

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Stargaming
; 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

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Stargaming
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

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread Stargaming
'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

Re: Keyword argument 'from'; invalid syntax

2007-07-25 Thread Stargaming
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_

Re: Scope PyQt question

2007-07-26 Thread Stargaming
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

Re: question about math module notation

2007-07-26 Thread Stargaming
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

Re: cls & self

2007-07-25 Thread Stargaming
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

Re: Bug? exec converts '\n' to newline in docstrings!?

2007-07-30 Thread Stargaming
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

Re: Python end of file marker similar to perl's __END__

2007-07-31 Thread Stargaming
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

Re: Python end of file marker similar to perl's __END__

2007-08-01 Thread Stargaming
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

Re: Assertion in list comprehension

2007-08-01 Thread Stargaming
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

Re: a dict trick

2007-08-02 Thread Stargaming
`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

Re: Auto run/Timer

2007-08-04 Thread Stargaming
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

Re: Something in the function tutorial confused me.

2007-08-06 Thread Stargaming
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

Re: Something in the function tutorial confused me.

2007-08-06 Thread Stargaming
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

Re: boolean operations on sets

2007-08-06 Thread Stargaming
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

Re: worker thread catching exceptions and putting them in queue

2007-03-05 Thread Stargaming
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

Re: Newbie question

2007-03-05 Thread Stargaming
) 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

Re: New to Python

2007-03-05 Thread Stargaming
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),

Re: any better code to initalize a list of lists?

2007-03-11 Thread Stargaming
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]

Re: New to Python

2007-03-12 Thread Stargaming
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) ? >>

Re: print and softspace in python

2007-03-14 Thread Stargaming
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

Re: #!/usr/bin/env python > 2.4?

2007-03-20 Thread Stargaming
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

Re: How to copy a ClassObject?

2007-03-20 Thread Stargaming
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

Re: #!/usr/bin/env python > 2.4?

2007-03-21 Thread starGaming
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.

Re: #!/usr/bin/env python > 2.4?

2007-03-22 Thread starGaming
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

Re: #!/usr/bin/env python > 2.4?

2007-03-22 Thread starGaming
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

Re: Error when trying to pass list into function.

2007-04-02 Thread Stargaming
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

Re: frange() question

2007-09-20 Thread Stargaming
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

Re: Getting rid of bitwise operators in Python 3?

2007-09-21 Thread Stargaming
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

Re: can I run pythons IDLE from a command line??

2007-09-23 Thread Stargaming
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

Re: New to python

2007-09-29 Thread Stargaming
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

Re: Select as dictionary...

2007-10-01 Thread Stargaming
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

Re: Fwd: Using fractions instead of floats

2007-10-01 Thread Stargaming
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

Re: Combine two dictionary...

2007-10-01 Thread Stargaming
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

Re: Adding behaviour for managing "task" dependencies

2007-10-02 Thread Stargaming
@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

Re: supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

2007-10-05 Thread Stargaming
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

Re: struct.unpack less than 1 byte

2007-10-10 Thread Stargaming
into `construct`_:: >>> from construct import * >>> foo = BitStruct("foo", ... Octet("spam"), # synonym for BitField("spam", 8) ... BitField("ham", 12), ... BitField("eggs", 12) ... ) &g

Re: Declarative properties

2007-10-12 Thread Stargaming
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

Re: Observer implementation question ('Patterns in Python')

2007-10-12 Thread Stargaming
Adding `__call__` to this implementation should be easy. HTH, Stargaming -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic and lazy import

2007-10-16 Thread Stargaming
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

Re: Noob questions about Python

2007-10-18 Thread Stargaming
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()`

Re: C++ version of the C Python API?

2007-10-19 Thread Stargaming
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

Re: class vs type

2007-10-19 Thread Stargaming
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

Re: pydoc script.py vs. pydoc scriptpy

2007-10-22 Thread Stargaming
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

Re: tuples within tuples

2007-10-26 Thread Stargaming
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

Re: arguments of a function/metaclass

2007-01-16 Thread Stargaming
eadable, but that's it). To bring up a more liberate attempt, why don't you just save *all* args received (self.__dict__.update(kwargs)). If the user provides more arguments -- nevermind! You would have to do something about default values though and here you got to use the list again, first updating self.__dict__ with the list and afterwards with kwargs. Stargaming -- http://mail.python.org/mailman/listinfo/python-list

Re: from future module!!!!!!!

2007-01-28 Thread Stargaming
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

Re: howto redirect and extend help content ?

2007-01-28 Thread Stargaming
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

Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Stargaming
: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

Re: where has Stani's Py Editor gone?

2007-01-31 Thread Stargaming
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

Re: from... import...

2007-02-02 Thread Stargaming
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

Re: randomly generate n of each of two types

2007-02-11 Thread Stargaming
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

Re: (beginners question) howto set self.field4.subfield8='asdf'?

2007-02-19 Thread Stargaming
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

Re: Can local function access local variables in main program?

2007-11-02 Thread Stargaming
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

Re: how to pass a function name and its arguments inside the arguments of other function?

2007-11-03 Thread Stargaming
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

Re: why it is invalid syntax?

2007-11-22 Thread Stargaming
;> >> -- >> -- 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

Re: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread Stargaming
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) >>

Re: Any way to program custom syntax to python prompt? >> I want to edit matrices.

2007-12-10 Thread Stargaming
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; >

Re: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread Stargaming
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

Re: Job Offer: Python Ninja or Pirate!

2007-12-14 Thread Stargaming
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

  1   2   >