Re: object knows which object called it?

2009-04-07 Thread afriere
On Apr 7, 2:53 am, "R. David Murray" 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 dispatch. +1 Whic

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: Does Python have certificate?

2009-03-25 Thread afriere
On Mar 24, 12:50 pm, Johannes Bauer 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! I can buy a Do

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?

Re: Python to Perl transalators

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

Re: How to do this in Python?

2009-03-18 Thread afriere
On Mar 18, 3:05 pm, Grant Edwards 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). Surel

Re: Reference or Value?

2009-02-22 Thread afriere
On Feb 23, 2:13 am, Torsten Mohr 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 refer

Re: Avoiding argument checking in recursive calls

2009-02-10 Thread afriere
On Feb 11, 1:48 pm, Jervis Whitley 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 one. It

Re: Couple of noobish question

2009-02-04 Thread afriere
On Feb 5, 11:45 am, Tim Rowe 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 be digging

Re: Couple of noobish question

2009-02-04 Thread afriere
On Feb 5, 11:14 am, Tim Rowe 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 seems to be a Wind

Re: I'm a python addict !

2009-01-28 Thread afriere
On Jan 27, 4:52 am, Paul McGuire 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 two obvious pr

Re: English-like Python

2009-01-20 Thread afriere
On Jan 16, 12:02 pm, The Music Guy 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 would be to make a pro