Re: object knows which object called it?

2009-04-07 Thread afriere
On Apr 7, 2:53 am, R. David Murray rdmur...@bitdance.com wrote: I think the OO way to do this is to provide a method on A that does the right thing:     def Bfoo_func(self):         self.B.foo_func(self) Or maybe you could look at generic methods, which provide a way to do multiple

Re: Does Python have certificate?

2009-03-25 Thread afriere
On Mar 24, 12:50 pm, Johannes Bauer dfnsonfsdu...@gmx.de wrote: Sebastian Bassi schrieb: I'll hand out the Johannes Bauer Python Certificate of Total Awesomeness for anyone who can write a hello world in python and hands me $25000 in cash. $25,000?! For a certificate? You must be kidding!

Re: file open fails.

2009-03-25 Thread afriere
Wouldn't it be easier just to avoid the windows slashes altogether and stick to the posix: title = 'c:/thesis/refined_title.txt' -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python 3 for scripting?

2009-03-22 Thread afriere
On Mar 23, 5:59 am, timo.my...@gmail.com (Timo Myyrä) wrote: I might get summer job in doing some 2nd tier support and doing some scripting besides that in Solaris environment. I gotta see what kind of scripts are needed but I'd guess the 2.6 would be the safest option. Timo Solaris? In

Re: How to do this in Python?

2009-03-18 Thread afriere
On Mar 18, 3:05 pm, Grant Edwards gra...@visi.com wrote: {snip] ... If it only going to be used once, then just do the usual thing: f = open(...) while True:    buf = f.read()    if not buf: break    # whatever. f.close() +1 That's the canonical way (maybe using with ... as nowadays).

Re: Python to Perl transalators

2009-03-18 Thread afriere
On Mar 18, 1:32 am, Armin feng.sh...@gmail.com wrote: On Wednesday 18 March 2009 11:01:00 Boris Borcic wrote: Armin wrote: humor Why on earth would you want to? That'd be like translating Shakespeare into a bad rap song! /humor lol, actually I would prefer a rap song over

Re: Reference or Value?

2009-02-22 Thread afriere
On Feb 23, 2:13 am, Torsten Mohr tm...@s.netic.de wrote: Hi, how is the rule in Python, if i pass objects to a function, when is this done by reference and when is it by value? def f1(a):     a = 7 b = 3 f1(b) print b = 3 Integers are obviously passed by value, lists and dicts by

Re: Avoiding argument checking in recursive calls

2009-02-10 Thread afriere
On Feb 11, 1:48 pm, Jervis Whitley jervi...@gmail.com wrote: Hello, an idea is optional keyword arguments. def fact(n, check=False):   if not check:     if n 0: raise ValueError   if n == 0: return 1   return fact(n - 1, check=True) * n essentially hiding an expensive check with a cheap

Re: Couple of noobish question

2009-02-04 Thread afriere
On Feb 5, 11:14 am, Tim Rowe digi...@gmail.com wrote: ... On an MS Windows system, os.uname()[0] raises an AttributeError -- sys doesn't seem to contain uname. Is that a Linux thing? Would os.name work on Linux? Or would one have to use exception handling and catch the Windows case? It

Re: Couple of noobish question

2009-02-04 Thread afriere
On Feb 5, 11:45 am, Tim Rowe digi...@gmail.com wrote: [snip] Python in a Nutshell states that os.uname exists only on certain platforms, and in the code sample wraps it in a try statement. That seems to be the safe way to go -- except (and I don't know much about this) wouldn't code have to

Re: I'm a python addict !

2009-01-28 Thread afriere
On Jan 27, 4:52 am, Paul McGuire pt...@austin.rr.com wrote: [snip]     # how you have to do it in C++ and Java     # light = light.next_state()     # using Python     light.__class__ = light.next_state I'm sure you can, but why poke yourself in the eye with a blunt stick? ;) IMO there are

Re: English-like Python

2009-01-20 Thread afriere
On Jan 16, 12:02 pm, The Music Guy music...@alphaios.net wrote: Just out of curiousity, have there been any attempts to make a version of Python that looks like actual English text? I mean, so much of Python is already based on the English language that it seems like the next natural step