Recommended data structure/ implementation

2008-02-12 Thread Mike D
I have a simple requirement: A user belongs to groups and groups contain items. Based on user/group I want to display items. Based on user I want to display groups. What would be the best method of implementing this? A dictionary of objects? I'd usually just use a database but I feel it's quite

Re: Difficulty with "inconsistent use of tabs and spaces in indentation" in file called

2008-02-12 Thread Gabriel Genellina
En Wed, 13 Feb 2008 03:01:31 -0200, greg <[EMAIL PROTECTED]> escribi�: > ibloom wrote: >> Of course I didn't understand that py2app was trying to compile my own >> python source code and when I switched to Xcode as my new editor, I >> started mixing in tabs. So was in fact my code. > > Seems li

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-12 Thread Erik Max Francis
Jeroen Ruigrok van der Werven wrote: > -On [20080212 22:15], Dotan Cohen ([EMAIL PROTECTED]) wrote: >> Note that Google will give a calculator result for "1 kilogram in >> pounds", but not for "1 kilogram in inches". I wonder why not? After >>

Re: Difficulty with "inconsistent use of tabs and spaces in indentation" in file called

2008-02-12 Thread Gabriel Genellina
En Tue, 12 Feb 2008 22:57:01 -0200, ibloom <[EMAIL PROTECTED]> escribi�: > On Feb 11, 9:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> >> >> : inconsistent use of tabs and spaces in indentation >> >> Traceback (most recent call last): >> >>   File "/Library/Frameworks/Python.framework/

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-12 Thread Erik Max Francis
greg wrote: > Erik Max Francis wrote: >> My point was, and still is, that if this question without further >> context is posed to a generally educated laymen, the supposedly wrong >> answer that was given is actually _correct_. > > Except that they probably don't understand exactly how and > wh

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-12 Thread Jeroen Ruigrok van der Werven
-On [20080212 22:15], Dotan Cohen ([EMAIL PROTECTED]) wrote: >Note that Google will give a calculator result for "1 kilogram in >pounds", but not for "1 kilogram in inches". I wonder why not? After >all, both are conversions of incompatible measurements, ie, they &

Re: Double underscore names

2008-02-12 Thread Erik Max Francis
Ben Finney wrote: > The double-underscore convention seems more for attributes *that are > interpreted specially*, e.g. by syntax operators or other core > language features. I would qualify that by adding that it's for attributes that are treated specially _and when you don't want to overload o

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-12 Thread greg
Erik Max Francis wrote: > My point was, and still is, that if this question without further > context is posed to a generally educated laymen, the supposedly wrong > answer that was given is actually _correct_. Except that they probably don't understand exactly how and why it's correct. E.g. the

Re: mmap and shared memory

2008-02-12 Thread Jeff Schwab
greg wrote: > Carl Banks wrote: >> In C you can use the mmap call to request a specific physical location >> in memory (whence I presume two different processes can mmap anonymous >> memory block in the same location) > > Um, no, it lets you specify the *virtual* address in the process's > address

Re: Difficulty with "inconsistent use of tabs and spaces in indentation" in file called

2008-02-12 Thread greg
ibloom wrote: > Of course I didn't understand that py2app was trying to compile my own > python source code and when I switched to Xcode as my new editor, I > started mixing in tabs. So was in fact my code. Seems like py2app could be a bit friendlier about reporting syntax errors in the code it's

Re: mmap and shared memory

2008-02-12 Thread greg
Carl Banks wrote: > In C you can use the mmap call to request a specific physical location > in memory (whence I presume two different processes can mmap anonymous > memory block in the same location) Um, no, it lets you specify the *virtual* address in the process's address space at which the obj

Re: Combinatorics

2008-02-12 Thread Raymond Hettinger
On Feb 11, 11:52 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > Where is the python equivalent of: > > http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatoric... > > combinations (with and without repetition) > variations (with and without repetition) > permutations > partitions >

Re: ways to declare empty set variable

2008-02-12 Thread George Sakkis
On Feb 12, 9:30 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > > > That makes it even more a violation of > > > principle-of-least-astonishment that the '(foo)' form doesn't give > > > a one-e

Re: Double underscore names

2008-02-12 Thread Steven Bethard
Steven D'Aprano wrote: > Double-underscore names and methods are special to Python. Developers are > prohibited from creating their own (although the language doesn't enforce > that prohibition). From PEP 0008, written by Guido himself: > > __double_leading_and_trailing_underscore__: "magi

RE: Is there a way to use .NET DLL from Python

2008-02-12 Thread Dino Viehland
>> >> Oh, I know what you mean. >> But that was exactly the reason for having a .DLLs folder, isn't it? >> When you place an assembly into this folder, you avoid having to write >> this boilerplate code, and simply import the assembly as you would >> with a normal python module. At least, that´s ho

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 7:31 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: > > >> What is dream hardware for the Python interpreter? > > > I'm not sure that the Python interpreter actually does dream, but if it's > > anything like m

Re: call 'the following function' using decorators

2008-02-12 Thread castironpi
On Feb 12, 12:10 pm, [EMAIL PROTECTED] wrote: > On Feb 12, 12:05 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > > > > > > En Tue, 12 Feb 2008 15:20:32 -0200, <[EMAIL PROTECTED]> escribi�: > > > > I assert it's easier to write: > > > > start_new_thread( this_func ) > > > def thrA(): > > >

Re: Possible to tack on random stuff to objects?

2008-02-12 Thread Cruxic
That does the trick. Thanks, Bruno. On Feb 12, 1:23 am, Bruno Desthuilliers wrote: > Cruxic a écrit : > > > Is it possible to tack on arbitrary attributes to a python object? > > Depends on the object's class. In the common case it's possible but > there are a couple cases - mostly builtin immut

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: > > That makes it even more a violation of > > principle-of-least-astonishment that the '(foo)' form doesn't give > > a one-element tuple literal. > > The reason being, of course, that in this

infinite loop when starting pdb

2008-02-12 Thread AndrewStone
I am starting pdb.pm() in an embedded, multithreaded python PyCrust shell (wx toolkit) -- but other than that it's COMPLETELY vanilla :-)) and pdb is getting stuck in an infinite loop, sucking down all CPU. I never get the pdb prompt. Anyone have any experience with this? I'm pretty new at thre

Re: ways to declare empty set variable

2008-02-12 Thread George Sakkis
On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > Ben Finney wrote: > > [...] > > > > Note that '()' is syntactically null. Parentheses don't declare a > > > tuple literal, commas do. Parentheses are for grouping within > > > expressions, not s

Re: *Oven-roasted* garlic?

2008-02-12 Thread Asun Friere
On Feb 13, 12:31 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > *Oven-roasted* garlic? OK, that's just weird. Not weird -- delicious! Try doing it like this: Take a whole knob unpeeled dribble on some olive oil and black pepper and bake in a medium oven for 10-15 mins. Pull apart into individual

PyCon: deadline for hotel reservations and early-bird registration coming soon!

2008-02-12 Thread David Goodger
If you haven't registered for PyCon yet, now is the time! The early-bird registration deadline is February 20, one week away. After that, the price for registration will be going up. http://us.pycon.org/2008/registration/ The deadline for hotel reservations at the conference rate is also F

Re: dream hardware

2008-02-12 Thread Ben Finney
Jeff Schwab <[EMAIL PROTECTED]> writes: > *Oven-roasted* garlic? OK, that's just weird. Why, where do you roast your garlic? -- \"Crime is contagious ... if the government becomes a | `\lawbreaker, it breeds contempt for the law." -- Justice Louis | _o__)

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
[EMAIL PROTECTED] writes: > Ben Finney: > > Generator literals do not require the parens at all. However, the > > syntax of where the generator literal *appears* can make it > > necessary to explicitly group the expression using parens. > > Have you taken a look at Boo? > In Python this isn't pos

Re: dream hardware

2008-02-12 Thread Jeff Schwab
Steven D'Aprano wrote: > On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: > >> What is dream hardware for the Python interpreter? > > I'm not sure that the Python interpreter actually does dream, but if it's > anything like me, it's probably a giant computer the size of a bus, made > out o

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 4:51 pm, "Martin P. Hellwig" <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann wrote: > > Jeff Schwab wrote: > > >> The only "dream hardware" I know of is the human brain. > > > Nah. Too few storage capacity, and too slow and error-prone at > > simple calculations. The few special but ver

Unbuffered mode

2008-02-12 Thread Hamish Allan
Hi, The man page for python says: "-u Force stdin, stdout and stderr to be totally unbuffered." However, when I try: $ ssh localhost python -u print 'hello, world' [^D] hello, world $ Nothing happens until I send that EOF. I'm pretty sure it's not SSH that's buffering because when I try:

Re: Difficulty with "inconsistent use of tabs and spaces in indentation" in file called

2008-02-12 Thread ibloom
On Feb 11, 9:10 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 11 Feb 2008 21:57:00 -0200, ibloom <[EMAIL PROTECTED]> escribió: > > > My main problem is, I don't know where to find the file: > >   File "", line 628 > > > As in I don't know what code it is refering to by ?? > > It isn

Re: ways to declare empty set variable

2008-02-12 Thread bearophileHUGS
Ben Finney: > Generator literals do not require the > parens at all. However, the syntax of where the generator literal > *appears* can make it necessary to explicitly group the expression > using parens. Have you taken a look at Boo? In Python this isn't possible: s = char for char in string.digi

Re: Getting a Foothold on the IDLE Debugger

2008-02-12 Thread Nir
On Feb 12, 7:15 am, "W. Watson" <[EMAIL PROTECTED]> wrote: > I thought I try to step through some simplePythoncode I wrote with IDLE > using Debug. I'm at the early stages of learningPython. I used the shell to > Run, then clicked on Debug->Debugger. That brought up a window with Stack > and Locals

Re: How to broad cast ping address.......

2008-02-12 Thread Gabriel Genellina
En Mon, 11 Feb 2008 23:26:14 -0200, Steve Holden <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: >> En Mon, 11 Feb 2008 13:31:56 -0200, Manikandan R <[EMAIL PROTECTED]> >> escribió: >> >>> I am working in Python scripting. I an need to find out all the >>> device >>> connected in th

Getting Wireless Signal Strength / Windows XP

2008-02-12 Thread williambattersea
Hello, I'm looking for a way to get wireless signal strength on Windows XP with Python. I see there's a library for Linux, but I can't find anything for windows. However, I see that using WMI I can access it in theory at least, using a query like "select Ndis80211ReceivedSignalStrength from MSNdis

Re: bluetooth file transfer in python

2008-02-12 Thread Paul Boddie
On 12 Feb, 10:50, chartsoft <[EMAIL PROTECTED]> wrote: > I am a teacher and need to set up a computer with a bluetooth dongle > to poll for mobile phones with bluetooth switched on in the area then > send them a jpg file. I guess you'd use OBEX to send the file, specifically using the "push" mode

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
[EMAIL PROTECTED] writes: > In Python ( ) denote: > - expression grouping > - they are very often used to denote tuples (despite being necessary > only for the empty one) > - generators (x for x in ...). > The Boo language shows that () aren't that necessary for the > generators. Now, that one I

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
Steve Holden <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > [...] > > > > Note that '()' is syntactically null. Parentheses don't declare a > > tuple literal, commas do. Parentheses are for grouping within > > expressions, not specifying type. > > > Tell that to the interpreter: > > >>> type((

Re: Recursive generator

2008-02-12 Thread Paul Hankin
On Feb 12, 10:17 pm, Ben C <[EMAIL PROTECTED]> wrote: > On 2008-02-12, Paul Rubin <> wrote: > > > Paul Hankin <[EMAIL PROTECTED]> writes: > >> def genDescendants(self): > >>     return chain([self], *[child.genDescendants() > >>         for child in self.children]) > > > That is scary.  It generate

Re: ways to declare empty set variable

2008-02-12 Thread Steve Holden
Ben Finney wrote: [...] > > Note that '()' is syntactically null. Parentheses don't declare a > tuple literal, commas do. Parentheses are for grouping within > expressions, not specifying type. > Tell that to the interpreter: >>> type(()) >>> tuple() is () True >>> regards Steve -- Steve

Re: ways to declare empty set variable

2008-02-12 Thread bearophileHUGS
Ben Finney: > I often use these myself. They're slightly more explicit, which can > help when I want the reader not to have to think too much, and they're > not particularly verbose because the names are well-chosen and short. I'd like "list" be called "array" ;-) > Note that '()' is syntactical

Re: Can anyone help, please?

2008-02-12 Thread Paul McGuire
On Feb 12, 4:10 pm, maehhheeyy <[EMAIL PROTECTED]> wrote: > Hi, right now I'm using Python and Multicast. I have the code for > Multicast receiver on Python but I keep getting this error; > > File "", line 1, in bind > error: (10049, "Can't assign requested address") > > The error is coming from th

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
[EMAIL PROTECTED] writes: > For Python 3.0 I'd like {} for the empty set and {:} for the empty > dict, but that idea was refused time ago, probably for some mental > backward compatibility. I agree with not breaking that backward compatibility; it seems wanton. > Missing that, I think dict() and

Re: Double underscore names

2008-02-12 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> writes: > having the ability to create a protocol is a Very Good Thing, and > double leading and trailing underscore names are the accepted Python > style for such special methods. Is it? There are many protocols that use plain names. Even the built-in types su

Re: Double underscore names

2008-02-12 Thread Christian Heimes
Steven D'Aprano wrote: > So what do folks think? I believe the protocol idiom ("look for a method > called __parrot__ and then do something with it") is too useful and > powerful to be ignored, but then if __parrot__ is reserved by Python, > what to do? The Python core claims all rights for __m

Re: dream hardware

2008-02-12 Thread Martin P. Hellwig
Bjoern Schliessmann wrote: > Jeff Schwab wrote: > >> The only "dream hardware" I know of is the human brain. > > Nah. Too few storage capacity, and too slow and error-prone at > simple calculations. The few special but very advanced features are > all hard-wired to custom hardware, it's a real ni

Re: ways to declare empty set variable

2008-02-12 Thread bearophileHUGS
Paul Rubin: > In 3.0 you may be able to say {,} but there is a contingent that would > just as soon get rid of all that special syntax, so you'd say list() > instead of [], dict() instead of {}, etc. For Python 3.0 I'd like {} for the empty set and {:} for the empty dict, but that idea was refused

Re: Combinatorics

2008-02-12 Thread Jaap Spies
Robert Dodier wrote: > Cameron Laird wrote: > >> Should combinatorics be part of the standard library? That's >> an aesthetic-pragmatic question I don't feel competent to >> answer; I look to timbot and Guido and so on for judgment there. >> It does occur to me, though, that even more widely appl

Double underscore names

2008-02-12 Thread Steven D'Aprano
Double-underscore names and methods are special to Python. Developers are prohibited from creating their own (although the language doesn't enforce that prohibition). From PEP 0008, written by Guido himself: __double_leading_and_trailing_underscore__: "magic" objects or attributes th

Re: Recursive generator

2008-02-12 Thread Ben C
On 2008-02-12, Paul Rubin <> wrote: > Paul Hankin <[EMAIL PROTECTED]> writes: >> def genDescendants(self): >> return chain([self], *[child.genDescendants() >> for child in self.children]) > > That is scary. It generates an in-memory list the size of the > whole subtree, at every level.

Re: dream hardware

2008-02-12 Thread Warren Myers
/me no longer wishes to know about your dreams. WMM On Feb 12, 2008 4:56 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: > > > What is dream hardware for the Python interpreter? > > I'm not sure that the Python interpreter actually does dream

Can anyone help, please?

2008-02-12 Thread maehhheeyy
Hi, right now I'm using Python and Multicast. I have the code for Multicast receiver on Python but I keep getting this error; File "", line 1, in bind error: (10049, "Can't assign requested address") The error is coming from this line; sock.bind ((MCAST_ADDR, MCAST_PORT)) This is the code that

Re: Getting a Foothold on the IDLE Debugger

2008-02-12 Thread Gabriel Genellina
En Tue, 12 Feb 2008 04:23:17 -0200, W. Watson <[EMAIL PROTECTED]> escribió: > BTW, what's with the close and exit options on the File menu? They both > dump > me out of IDLE. Odd. Try File|New > Any idea of whether I can "glue" the File-?Open to a > particular folder? Mmm, no. But it rememb

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 3:42 pm, Bjoern Schliessmann wrote: > Jeff Schwab wrote: > > The only "dream hardware" I know of is the human brain. > > Nah. Too few storage capacity, and too slow and error-prone at > simple calculations. The few special but very advanced features are > all hard-wired to custom hardwa

MatPy question

2008-02-12 Thread Xin Ye
I am using Python 2.5. I wonder how to use MatPy in this version of Python. Xin No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.20.2/1272 - Release Date: 2/11/2008 5:28 PM -- http://mail.python.org/mailman/listinfo/python-list

Re: dream hardware

2008-02-12 Thread Steven D'Aprano
On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: > What is dream hardware for the Python interpreter? I'm not sure that the Python interpreter actually does dream, but if it's anything like me, it's probably a giant computer the size of a bus, made out of broccoli and oven-roasted garlic,

Re: IDLE Won't Start w/o Socket Error--Win XP

2008-02-12 Thread W. Watson
Thanks. That did the trick. Mike Driscoll wrote: > On Feb 12, 2:18 pm, "W. Watson" <[EMAIL PROTECTED]> wrote: >> After simply trying to write a program with help(MakeQTE), a module, and >> having it fail with socket errors, I decided to restart IDLE, thinking I ... > > I sometimes get this messag

Re: Is there a web visitor counter available in Python ...

2008-02-12 Thread Dotan Cohen
On 12/02/2008, W. Watson <[EMAIL PROTECTED]> wrote: > PHP. Well, that's a new one on me. Google gave me some idea of what it's > about, and I found some code on how to do it. It requires yet another > "programming language", which means finding the editor, etc. Any text editor will do PHP. I per

Re: dream hardware

2008-02-12 Thread Bjoern Schliessmann
Jeff Schwab wrote: > The only "dream hardware" I know of is the human brain. Nah. Too few storage capacity, and too slow and error-prone at simple calculations. The few special but very advanced features are all hard-wired to custom hardware, it's a real nightmare interfacing with it. Regards,

Re: ways to declare empty set variable

2008-02-12 Thread Ben Finney
"Sun" <[EMAIL PROTECTED]> writes: > I was wondering why can't I use a format as "var = {} " to > "var=list()" in set variable, and decided not to bother with it. Python 3.0 will gain syntax to specify a literal of type 'set' http://www.python.org/dev/peps/pep-3100/>:: >>> {17, "foo", 12.5}

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 2:15 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Feb 12, 1:05 pm, [EMAIL PROTECTED] wrote: > > > What is dream hardware for the Python interpreter? > > A 10 GHz single core. > > (Dual core if doing lots of I/O.) > > Carl Banks Handle a dual 6GHz core. Code sometimes happens in order

Re: ways to declare empty set variable

2008-02-12 Thread Paul Rubin
"Sun" <[EMAIL PROTECTED]> writes: > I was wondering why can't I use a format as "var = {} " to "var=list()" in > set variable, and decided not to bother with it. In 3.0 you may be able to say {,} but there is a contingent that would just as soon get rid of all that special syntax, so you'd say l

Re: ways to declare empty set variable

2008-02-12 Thread Gabriel Genellina
En Tue, 12 Feb 2008 12:04:43 -0200, Sun <[EMAIL PROTECTED]> escribió: > "Chris" <[EMAIL PROTECTED]> wrote > test = set() > test >> set([]) > > yeah, that 's what I am looking for, thanks all for such prompt answers! > > I was wondering why can't I use a format as "var = {} " to "var=list()

Re: How to access object attributes given a string

2008-02-12 Thread Santiago Romero
This is faster: http://www.sromero.org/python/zx_parseexec.py http://www.sromero.org/python/test.par XD -- http://mail.python.org/mailman/listinfo/python-list

Re: How to access object attributes given a string

2008-02-12 Thread Santiago Romero
And the rest of the code: # def ExecParser_Exec( exec_type, code, game, debug=0 ): """ Execute the previously "compiled" code: """ code_level = 0 #player = game.player #world = game.world # Take only opco

Re: Unicode char replace

2008-02-12 Thread DiMar
On 12 Feb, 22:11, Michael Goerz <[EMAIL PROTECTED]> wrote: > How about this? > string.replace(u'\xbb', u'»') Thanks, it works!!! DiMar -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode char replace

2008-02-12 Thread DiMar
> May I ask why? Of course! I have to find that string into a list of strings. This list includes one, using » Thanks! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode char replace

2008-02-12 Thread Michael Goerz
DiMar wrote, on 02/12/2008 09:54 PM: > Hi all, > > I have this unicode string: > > string = u'Macworld » Jobs 1 - Twitter 0' > > and I want to replace the '»' (aka \xbb) char to '»'. > I've tried 2 ways: > > 1. string2 = string.replace('\\xbb','»') > u'Macworld \xbb Jobs 1 - Twitter 0' How

Re: IronPython vs CPython: faster in 1.6 times?

2008-02-12 Thread Fuzzyman
On Feb 12, 7:49 pm, [EMAIL PROTECTED] wrote: > Fuzzyman: > > > Another interesting little benchmark of CPython and IronPython. Can't > > see the code, but it looks like an implementation of the 11 queens > > problem and IronPython comes out a clear winner on this one. (Looks > > like no benchmark f

Re: IDLE Won't Start w/o Socket Error--Win XP

2008-02-12 Thread Gabriel Genellina
En Tue, 12 Feb 2008 18:18:20 -0200, W. Watson <[EMAIL PROTECTED]> escribió: > After simply trying to write a program with help(MakeQTE), a module, and > having it fail with socket errors, I decided to restart IDLE, thinking I > knew the cause. I'm now getting msgs like: "IDLE's subprocess didn't

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-12 Thread Dotan Cohen
On 12/02/2008, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Dennis Lee Bieber wrote: > > > On Tue, 12 Feb 2008 00:18:38 -0800, Erik Max Francis <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > > >> equivalence for everyday usage and make no requirement of using the > >

Re: How to access object attributes given a string

2008-02-12 Thread Santiago Romero
And the big functions: I imagine that the following is HORRIBLE in the pythonic-vision and surely can be rewriten with a single map+reduce+filter + 200 lambdas functions X-D, but I come from C and any advice on how to implement my "simple scripting language" without using lex or yacc is welcome

Re: Unicode char replace

2008-02-12 Thread Martin v. Löwis
> string = u'Macworld » Jobs 1 - Twitter 0' > > > None of them gives me 'Macworld » Jobs 1 - Twitter 0' > > Any idea? So I assume you *want* it to produce ». May I ask why? I really recommend that you use » instead. In any case, you need to define your own error handler, such as the one in ht

Re: How to access object attributes given a string

2008-02-12 Thread Santiago Romero
Before I reinvent the wheel, I'm going to post the code. Feel free to give any advice, and think that I'm new to python, it's only 1 month since I began programming in python "seriously" (up to that moment, I wrote just a few log-text parsing system administration scripts to speed up some old b

Re: Is there a web visitor counter available in Python ...

2008-02-12 Thread subeen
Well, you don't need to worry about code, you can just copy paste the code of the hit counters available for free. In my blog, http://love-python.blogspot.com/ I am using two type of hit counters (both are free). You can try them. They generate code that you just paste in the source code of your w

Re: How to access object attributes given a string

2008-02-12 Thread Steve Holden
Santiago Romero wrote: > Hi... > > I'm trying to guess how to access attributes of an existing object > given the attribute name in a string. I mean: > > class Object: > self.x = 12 > self.y = 20 > self.name = "blah" > > def ChangeAttribute( object, attribute, value ): > # Insert

Unicode char replace

2008-02-12 Thread DiMar
Hi all, I have this unicode string: string = u'Macworld » Jobs 1 - Twitter 0' and I want to replace the '»' (aka \xbb) char to '»'. I've tried 2 ways: 1. >>> string2 = string.replace('\\xbb','»') u'Macworld \xbb Jobs 1 - Twitter 0' 2. >>> import cgi >>> string2 = cgi.escape(string).encode("asc

Re: How to access object attributes given a string

2008-02-12 Thread Santiago Romero
> > def ChangeAttribute( object, attribute, value ): >help(setattr) > > Help on built-in function setattr in module __builtin__: > > setattr(...) setattr(object, name, value) > > Set a named attribute on an object; setattr(x, 'y', v) is > equivalent to`x.y = v''. and > Gary Herron write: > Yo

Re: How to access object attributes given a string

2008-02-12 Thread [EMAIL PROTECTED]
On 12 fév, 21:35, Dennis Kempin <[EMAIL PROTECTED]> wrote: > Santiago Romero schrieb: (snip - others already answered) > > PS: I need it for a concrete case in a game scripting language I'm > > writing, so that I can call functions like "CHANGE_PLAYER_VALUES( "x", > > 100 )". > > You are using a sc

Re: How to access object attributes given a string

2008-02-12 Thread Dennis Kempin
Santiago Romero schrieb: > Hi... > > I'm trying to guess how to access attributes of an existing object > given the attribute name in a string. I mean: > > class Object: > self.x = 12 > self.y = 20 > self.name = "blah" > > def ChangeAttribute( object, attribute, value ): > # Inse

Re: How to access object attributes given a string

2008-02-12 Thread Gary Herron
Santiago Romero wrote: > Hi... > > I'm trying to guess how to access attributes of an existing object > given the attribute name in a string. I mean: > > class Object: > self.x = 12 > self.y = 20 > self.name = "blah" > > def ChangeAttribute( object, attribute, value ): > # Insert he

Re: Recursive generator

2008-02-12 Thread Paul Rubin
Paul Hankin <[EMAIL PROTECTED]> writes: > def genDescendants(self): > return chain([self], *[child.genDescendants() > for child in self.children]) That is scary. It generates an in-memory list the size of the whole subtree, at every level. Total memory consumption is maybe even quadr

Re: How to access object attributes given a string

2008-02-12 Thread Chris
On Feb 12, 10:25 pm, Santiago Romero <[EMAIL PROTECTED]> wrote: > Hi... > > I'm trying to guess how to access attributes of an existing object > given the attribute name in a string. I mean: > > class Object: > self.x = 12 > self.y = 20 > self.name = "blah" > > def ChangeAttribute( o

Re: IDLE Won't Start w/o Socket Error--Win XP

2008-02-12 Thread Mike Driscoll
On Feb 12, 2:18 pm, "W. Watson" <[EMAIL PROTECTED]> wrote: > After simply trying to write a program with help(MakeQTE), a module, and > having it fail with socket errors, I decided to restart IDLE, thinking I > knew the cause. I'm now getting msgs like: "IDLE's subprocess didn't make > connection.

How to access object attributes given a string

2008-02-12 Thread Santiago Romero
Hi... I'm trying to guess how to access attributes of an existing object given the attribute name in a string. I mean: class Object: self.x = 12 self.y = 20 self.name = "blah" def ChangeAttribute( object, attribute, value ): # Insert here the code for object.attribute = value X

IDLE Won't Start w/o Socket Error--Win XP

2008-02-12 Thread W. Watson
After simply trying to write a program with help(MakeQTE), a module, and having it fail with socket errors, I decided to restart IDLE, thinking I knew the cause. I'm now getting msgs like: "IDLE's subprocess didn't make connection. ... firewall may be blocking the connection." I doubt the FW co

Re: dream hardware

2008-02-12 Thread Carl Banks
On Feb 12, 1:05 pm, [EMAIL PROTECTED] wrote: > What is dream hardware for the Python interpreter? A 10 GHz single core. (Dual core if doing lots of I/O.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Combinatorics

2008-02-12 Thread [EMAIL PROTECTED]
On Feb 12, 1:52 am, Michael Robertson <[EMAIL PROTECTED]> wrote: > Where is the python equivalent of: > > http://search.cpan.org/~fxn/Algorithm-Combinatorics-0.16/Combinatoric... > > combinations (with and without repetition) > variations (with and without repetition) > permutations > partitions >

Re: Dynamic method parameter access?

2008-02-12 Thread Chris
On Feb 12, 9:38 pm, Dennis Kempin <[EMAIL PROTECTED]> wrote: > Hello, > > I have a set of some objects. With these objects I want to call a Python > method. But the writer of the method shall have the option to select > from these objects as method parameter. > > At the moment i use the following w

Dynamic method parameter access?

2008-02-12 Thread Dennis Kempin
Hello, I have a set of some objects. With these objects I want to call a Python method. But the writer of the method shall have the option to select from these objects as method parameter. At the moment i use the following way to call a method with the a or b or both parameter. try: meth

Re: Combinatorics

2008-02-12 Thread bearophileHUGS
Cameron Laird: > It does occur to me, though, that even more widely applicable > than the combinatorics module of Mathematica (if only because of > its licensing) might be such resources as What I was trying to say is that that Mathematica combinatorics module contains lots and lots and lots of th

Re: IronPython vs CPython: faster in 1.6 times?

2008-02-12 Thread bearophileHUGS
Fuzzyman: > Another interesting little benchmark of CPython and IronPython. Can't > see the code, but it looks like an implementation of the 11 queens > problem and IronPython comes out a clear winner on this one. (Looks > like no benchmark for psyco.) If you want a more reliable set of benchmarks

Re: IDLE: Clearing Breakpoints and Find with Help

2008-02-12 Thread W. Watson
I'll add a couple more. I forgot to mention that it seems impossible to do a Ctrl-F for a "Find" within the Help text. Is there another way? Is it possible to set IDLE so that it goes to another folder other than the install folder when I start it? Why doe both close and exit do the same thing?

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 1:03 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > >>> What is dream hardware for the Python interpreter? > > > The only "dream hardware" I know of is the human brain.  I have a > > slightly used one myself, and it's a  pretty mediocre Python interpreter. > > the human brain may be a pretty

IDLE: Clearing Breakpoints and Find with Help

2008-02-12 Thread W. Watson
How does one clear all breakpoints or even list where they are? When looking at the source code, is it possible to tell which line number is used for a statement. When I bring up the Help--Python Docs, the link to how-to is broken. Release 2.4.4. -- Wayne Watson (Neva

Re: IronPython vs CPython: faster in 1.6 times?

2008-02-12 Thread Fuzzyman
On Feb 5, 5:31 pm, dmitrey <[EMAIL PROTECTED]> wrote: > Hi all, > the urlhttp://torquedev.blogspot.com/2008/02/changes-in-air.html > (blog of a game developers) > saysIronPythonis faster than CPython in 1.6 times. > Is it really true? > If yes, what areIronPythondrawbacks vs CPython? > And is it po

Re: dream hardware

2008-02-12 Thread Tim Chase
>>> What is dream hardware for the Python interpreter? > > The only "dream hardware" I know of is the human brain. I have a > slightly used one myself, and it's a pretty mediocre Python interpreter. the human brain may be a pretty mediocre Python interpreter, but darn if I don't miss >>> im

Re: C function in a Python context

2008-02-12 Thread castironpi
On Feb 9, 3:04 pm, [EMAIL PROTECTED] wrote: > On Feb 9, 1:48 pm, [EMAIL PROTECTED] wrote: > > > > > > > To write quick C things that Python won't do up to speed.  So it's got > > a redundancy. > > > import ext > > extA= ext.Ext() > > extA[ 'enumfactors' ]= r""" > >     int enumfactors( int a, const

Re: dream hardware

2008-02-12 Thread castironpi
On Feb 12, 12:31 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > > On Feb 12, 2008 1:05 PM,  <[EMAIL PROTECTED]> wrote: > >> What is dream hardware for the Python interpreter? > Warren Myers wrote: > >  > A Cray? >  > >  > What are you trying to do? "dream" hardware is a very wide question. > > The on

Re: Python equivt of __FILE__ and __LINE__

2008-02-12 Thread Jeff Schwab
Gabriel Genellina wrote: > En Tue, 12 Feb 2008 16:20:12 -0200, Jeff Schwab <[EMAIL PROTECTED]> > escribió: > >> What about the following? Should the underscores be omitted from the >> method names, for consistency with inspect? > > I prefer the names_with_underscore, the "current" style recomme

Re: Python equivt of __FILE__ and __LINE__

2008-02-12 Thread Gabriel Genellina
En Tue, 12 Feb 2008 16:20:12 -0200, Jeff Schwab <[EMAIL PROTECTED]> escribió: > What about the following? Should the underscores be omitted from the > method names, for consistency with inspect? I prefer the names_with_underscore, the "current" style recommended by PEP8 http://www.python.org

Re: dream hardware

2008-02-12 Thread Jeff Schwab
> On Feb 12, 2008 1:05 PM, <[EMAIL PROTECTED]> wrote: >> What is dream hardware for the Python interpreter? Warren Myers wrote: > A Cray? > > What are you trying to do? "dream" hardware is a very wide question. The only "dream hardware" I know of is the human brain. I have a slightly used

  1   2   >