Re: What other languages use the same data model as Python?

2011-05-07 Thread Chris Angelico
On Sun, May 8, 2011 at 4:16 PM, Dennis Lee Bieber wrote: > On Sun, 08 May 2011 10:54:57 +1200, Gregory Ewing > declaimed the following in > gmane.comp.python.general: > >> >> What would *you* call a[i]? >> >        Depending upon the nature of the beast, I'd be tempted to call it a > "fully quali

Re: Python3: imports don't see files from same directory?

2011-05-07 Thread Benjamin Kaplan
On Sat, May 7, 2011 at 11:04 PM, John O'Hagan wrote: > On Sat, 7 May 2011, Ian Kelly wrote: > [...] >> >> Implicit relative imports were removed in Python 3 to prevent >> ambiguity as the number of packages grows.  See PEP 328. >> >> If you have two modules in the same package, pack1.mod1 and >> p

Re: A suggestion for an easy logger

2011-05-07 Thread TheSaint
TheSaint wrote: > I'd like to just have the 4 conditions mentioned in the first post. > OK, my analysis led me to the print() function, which would suffice for initial my purposes. Meanwhile I reading the tutorials, but I couldn't get how to make a formatter to suppress or keep the LF(CR) at th

Re: Python3: imports don't see files from same directory?

2011-05-07 Thread John O'Hagan
On Sat, 7 May 2011, Ian Kelly wrote: [...] > > Implicit relative imports were removed in Python 3 to prevent > ambiguity as the number of packages grows. See PEP 328. > > If you have two modules in the same package, pack1.mod1 and > pack1.mod2, then in pack1.mod1 you can no longer just do "impor

Re: What other languages use the same data model as Python?

2011-05-07 Thread rusi
On May 8, 7:17 am, Steven D'Aprano wrote: > On Sat, 07 May 2011 21:21:45 +1200, Gregory Ewing wrote: > > Hans Georg Schaathun wrote: > > >> You cannot reference nor manipulate a reference in python, and that > >> IMHO makes them more abstract. > > > You can manipulate them just fine by moving them

Re: Fibonacci series recursion error

2011-05-07 Thread Robert Brown
Steven D'Aprano writes: > If you value runtime efficiency over development time, sure. There are > plenty of languages which have made that decision: Pascal, C, Java, > Lisp, Forth, and many more. I don't understand why you place Lisp and Forth in the same category as Pascal, C, and Java. Lisp

Re: checking if a list is empty

2011-05-07 Thread Ethan Furman
harrismh777 wrote: Steven D'Aprano wrote: >>> attribution lost wrote: > and implies in any case that li does not exist It does nothing of the sort. If li doesn't exist, you get a NameError. That was the point. 'not' implies something that is not logical; which is irony extreme sinc

Re: A suggestion for an easy logger

2011-05-07 Thread TheSaint
Vinay Sajip wrote: WoW :O , the creator !! > import logging > > logging.basicConfig(level=logging.DEBUG) I'm getting there, but the result it's not what I would. As far as I got to know, it should take to write a configuration file, which I still not aware of. I'd like to just have the 4 condi

Re: What other languages use the same data model as Python?

2011-05-07 Thread harrismh777
Steven D'Aprano wrote: Nobody talking about (say) Solitaire on a computer would say: "Blat the pixels in the rect A,B,C,D to the rect E,F,G,H. That will free up the Ace of Spades and allow you to memcopy the records in the far right column of the tableau into the foundation." but when it come

Re: checking if a list is empty

2011-05-07 Thread harrismh777
Steven D'Aprano wrote: ... if not li says nothing about what li is supposed to 'be' Yes, and? Neither does: isempty(li) # li could be anything that polymorphic isempty can deal with li.isempty() # li could be anything with a "isempty" method len(li) == 0 # li could be anything with a length

Re: Py 3.2: sqlite can't operate on a closed cursor

2011-05-07 Thread Gnarlodious
It turns out Python 3.2 now honors closing sqlite connections opened in another module. Previous versions allowed you to have identically named sqlite connections open in other modules. Python 3.2 apparently treats them all as the same connection. Hopefully some other victim will find this, becaus

Py 3.2: sqlite can't operate on a closed cursor

2011-05-07 Thread Gnarlodious
I installed Python 3.2, suddenly getting an error on my sqlite pages (CGI): ProgrammingError: Cannot operate on a closed cursor Works normally in interactive mode. Seems to error when the sqlite statement is in a function. Are sqlite objects now required to be declared global? -- Gnarlie -- htt

Re: A suggestion for an easy logger

2011-05-07 Thread Vinay Sajip
On May 8, 1:00 am, mcilrain wrote: > Aside from the fact that it's very Javay, what's wrong with theloggingmodule? It's not especially Java-like. Since you can log using just import logging logging.basicConfig(level=logging.DEBUG) logging.debug('This is %sic, not %s-like - that's FUD', 'Python'

Re: What other languages use the same data model as Python?

2011-05-07 Thread Steven D'Aprano
On Sat, 07 May 2011 21:21:45 +1200, Gregory Ewing wrote: > Hans Georg Schaathun wrote: > >> You cannot reference nor manipulate a reference in python, and that >> IMHO makes them more abstract. > > You can manipulate them just fine by moving them from one place to > another: > > a = b I se

Re: ABC-registered Exceptions are not caught as subclasses

2011-05-07 Thread Chris Rebert
On Sat, May 7, 2011 at 12:03 PM, andrew cooke wrote: > > This isn't hugely surprising, but doesn't seem to be documented.  Is it a > bug, or worth raising as one, or have I misunderstood? > > > Python 3.2 (r32:88445, Feb 27 2011, 13:00:05) > [GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] o

Re: What other languages use the same data model as Python?

2011-05-07 Thread Ben Finney
Gregory Ewing writes: > Ben Finney wrote: > > > No, I think not. The term “variable” usually comes with a strong > > expectation that every variable has exactly one name. > > I would say that many variables don't have names *at all*, unless you > consider an expression such as a[i] to be a "name"

Re: A suggestion for an easy logger

2011-05-07 Thread mcilrain
Aside from the fact that it's very Javay, what's wrong with the logging module? -- http://mail.python.org/mailman/listinfo/python-list

Re: is there an autocompletion like Dasher ?

2011-05-07 Thread Stef Mientki
On 08-05-2011 01:28, Dan Stromberg wrote: > > On Sat, May 7, 2011 at 3:40 PM, Stef Mientki > wrote: > > hello, > > I would like to have a autocompletion / help /snippet system like Dasher : > > http://www.inference.phy.cam.ac.uk/dasher/ > > anyone see

Re: What other languages use the same data model as Python?

2011-05-07 Thread Chris Angelico
On Sun, May 8, 2011 at 8:54 AM, Gregory Ewing wrote: > Ben Finney wrote: > >> No, I think not. The term “variable” usually comes with a strong >> expectation that every variable has exactly one name. > > I would say that many variables don't have names *at all*, > unless you consider an expression

Re: is there an autocompletion like Dasher ?

2011-05-07 Thread Dan Stromberg
On Sat, May 7, 2011 at 3:40 PM, Stef Mientki wrote: > hello, > > I would like to have a autocompletion / help /snippet system like Dasher : > > http://www.inference.phy.cam.ac.uk/dasher/ > > anyone seen such a component ? > Ummm... For what OS and what hardware? Do you need something that was

Re: Django/AppEngine DevSoup

2011-05-07 Thread Gregory Ewing
John wrote: There's eclipse, pydev, django non-rel, mediagenerator, etc Would it be stupid of me to just use the simple, clean notepad++ & django with aims to port into appengine after I finish in a week? I don't want to deal with all of the other stuff. Will this come back to haunt me in 7

Re: seems like a bug in isinstance()

2011-05-07 Thread Gregory Ewing
dmitrey wrote: Yes, you are right. But I have to do it due to another issue I haven't solved yet: Python3 imports don't see files from same directory http://groups.google.com/group/comp.lang.python/browse_thread/thread/9470dbdacc138709# That's because the syntax for relative imports has ch

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
Ben Finney wrote: No, I think not. The term “variable” usually comes with a strong expectation that every variable has exactly one name. I would say that many variables don't have names *at all*, unless you consider an expression such as a[i] to be a "name". And if you *do* consider that to be

is there an autocompletion like Dasher ?

2011-05-07 Thread Stef Mientki
hello, I would like to have a autocompletion / help /snippet system like Dasher : http://www.inference.phy.cam.ac.uk/dasher/ anyone seen such a component ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
Chris Angelico wrote: I think "manipulate" here means things like pointer arithmetic, I don't believe that allowing arithmetic on pointers is a prerequisite to considering them first-class values. You can't do arithmetic on pointers in Pascal, for example, but nobody argues that Pascal pointer

Re: dictionary size changed during iteration

2011-05-07 Thread Roy Smith
In article <7xd3jukyn9@ruckus.brouhaha.com>, Paul Rubin wrote: > Roy Smith writes: > > changes = [ ] > > for key in d.iterkeys(): > > if is_bad(key): > > changes.append(key) > > changes = list(k for k in d if is_bad(k)) > > is a little bit more direct. This is true. I still fi

Re: PyGTK notebook: get current page

2011-05-07 Thread Alexander Kapps
On 07.05.2011 17:04, Tracubik wrote: Hi all! I've made a simple PyGTK program. It's a window with a notebook, the notebook have 2 pages When changing page, i'ld like to get the id of current page. I've coded it, but i can get only the previously open page, not the current one. This is not a big

Re: dictionary size changed during iteration

2011-05-07 Thread Paul Rubin
Roy Smith writes: > changes = [ ] > for key in d.iterkeys(): > if is_bad(key): > changes.append(key) changes = list(k for k in d if is_bad(k)) is a little bit more direct. -- http://mail.python.org/mailman/listinfo/python-list

Re: Coolest Python recipe of all time

2011-05-07 Thread Raymond Hettinger
On May 7, 1:29 am, Steven D'Aprano wrote: > On Fri, 06 May 2011 12:36:09 -0600, Ian Kelly wrote: > > The amb engine would conceptually execute this function for every > > possible combination of a, b, and c, > > Which pretty much is the definition of "brute-force solver", no? FWIW, here's one of

Re: What other languages use the same data model as Python?

2011-05-07 Thread Roy Smith
In article <87aaeymfww@benfinney.id.au>, Ben Finney wrote: > No, I think not. The term “variable” usually comes with a strong > expectation that every variable has exactly one name. Heh. You've never used common blocks in Fortran? Or, for that matter, references in C++? I would call

Re: dictionary size changed during iteration

2011-05-07 Thread Laszlo Nagy
... That works, but if d is large, it won't be very efficient because it has to generate a large list. It is not large. But I'm using Python 2.6 , not Python 3. I did not get this error again in the last two days. I'll post a new reply if I encounter it again. (It happened just a few times o

Re: What other languages use the same data model as Python?

2011-05-07 Thread Ben Finney
Gregory Ewing writes: > > On Thu, 05 May 2011 07:43:59 +1000, Ben Finney wrote: > > > >>‘x’ is a name. Names are bound to values. Talk of “variable” only > >>confuses the issue because of the baggage carried with that term. > > But to use 'name' as a complete replacement for 'variable', I don't

ABC-registered Exceptions are not caught as subclasses

2011-05-07 Thread andrew cooke
This isn't hugely surprising, but doesn't seem to be documented. Is it a bug, or worth raising as one, or have I misunderstood? Python 3.2 (r32:88445, Feb 27 2011, 13:00:05) [GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2 Type "help", "copyright", "credits" or "license" for mo

Re: Python IDE/text-editor

2011-05-07 Thread emato
> On Apr 16, 1:20 pm, Alec Taylor wrote: > >> I'm looking for an IDE which offers syntax-highlighting, >> code-completion, tabs, gedit http://projects.gnome.org/gedit/index.html -- http://mail.python.org/mailman/listinfo/python-list

Django/AppEngine DevSoup

2011-05-07 Thread John
Sooo I have a windows box... which I like to think is the reason I'm a django/appengine mess right now. There's eclipse, pydev, django non-rel, mediagenerator, etc Would it be stupid of me to just use the simple, clean notepad++ & django with aims to port into appengine after I finish in a we

Re: Python3: imports don't see files from same directory?

2011-05-07 Thread Ian Kelly
On Sat, May 7, 2011 at 4:02 AM, dmitrey wrote: > hi all, > I try to port my code to Python 3 and somehow files don't see files > from same directory, so I have to add those directories explicitly, > e.g. > import sys > sys.path += [...] > > Also, it leads to bugs like this one: > http://groups.goo

PyGTK notebook: get current page

2011-05-07 Thread Tracubik
Hi all! I've made a simple PyGTK program. It's a window with a notebook, the notebook have 2 pages When changing page, i'ld like to get the id of current page. I've coded it, but i can get only the previously open page, not the current one. This is not a big deal if i have only 2 pages, but it co

Re: Coolest Python recipe of all time

2011-05-07 Thread Ian Kelly
On Sat, May 7, 2011 at 2:29 AM, Steven D'Aprano wrote: >> This isn't really amb; as you said it's just a brute-force solver with >> some weird syntax.  The whole point of amb is to enable >> non-deterministic programming, such as this: > [...] >> The amb engine would conceptually execute this func

Re: Custom string joining

2011-05-07 Thread Chris Rebert
On Sat, May 7, 2011 at 5:31 AM, Claudiu Popa wrote: > Hello Python-list, > > I  have  an object which defines some methods. I want to join a list or > an iterable of those objects like this: > > new_string = "|".join(iterable_of_custom_objects) > > What   is   the   __magic__  function that needs

Re: Stuck with urllib.quote and Unicode/UTF-8

2011-05-07 Thread Chris Rebert
On Sat, May 7, 2011 at 5:35 AM, Marian Steinbach wrote: > An addition/correction: > > It seems as if my input variable address is not Unicode. This is what > I get for print [address]: > > ['K\xf6ln, Nordrhein-Westfalen'] > > Isn't this utf-8 encoding? Nope, it's Latin-1 (or similar, e.g. Windows

Custom string joining

2011-05-07 Thread Claudiu Popa
Hello Python-list, I have an object which defines some methods. I want to join a list or an iterable of those objects like this: new_string = "|".join(iterable_of_custom_objects) What is the __magic__ function that needs to be implemented for this case to work? I though that __str__

Re: Stuck with urllib.quote and Unicode/UTF-8

2011-05-07 Thread Marian Steinbach
An addition/correction: It seems as if my input variable address is not Unicode. This is what I get for print [address]: ['K\xf6ln, Nordrhein-Westfalen'] Isn't this utf-8 encoding? And I'm using Python 2.5.2. -- http://mail.python.org/mailman/listinfo/python-list

Stuck with urllib.quote and Unicode/UTF-8

2011-05-07 Thread Marian Steinbach
Hi! I am stuck with calling URLs with parameters containing non-ASCII characters. I'm creating a url like this. url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' + urllib.quote(address) + '&sensor=false&language=DE' address can be a string like u"Köln, Nordrhein-Westfalen". Thi

Re: What other languages use the same data model as Python?

2011-05-07 Thread TheSaint
Gregory Ewing wrote: > because modern architectures are so freaking complicated > that it takes a computer to figure out the best instruction > sequence certainly is, I would not imagine one who writes on scraps of paper :D :D :D -- goto /dev/null -- http://mail.python.org/mailman/listinfo/py

Re: What other languages use the same data model as Python?

2011-05-07 Thread Grant Edwards
On 2011-05-07, Gregory Ewing wrote: > Grant Edwards wrote: >> if you feel it just right and you have just the >>>right synchro-mesh setup, you can slide from 3rd into 4th without >>>every touching the clutch peddle... >> >>>and if that isn't automatic, I don't know what is >> >> No, that's _

A suggestion for an easy logger

2011-05-07 Thread TheSaint
Hello, I've resumed my hold project and I like to convert it for py3k2. My knowledge has stagnated at version 2.4, then I found some improvements, but it will take me some time before I get used to. I was using this logger >> ===

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
Grant Edwards wrote: if you feel it just right and you have just the right synchro-mesh setup, you can slide from 3rd into 4th without every touching the clutch peddle... and if that isn't automatic, I don't know what is No, that's _not_ automatic if you have to do it yourself. It's au

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
Andreas Tawn wrote: If True and False: waveFunction.collapse(cat) Call-by-entanglement would be interesting. Anything that the callee does to the parameter would affect the caller, but you would only be able to tell by examining a trace of the output afterwards. -- Greg -- http://mail.pyt

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
On Thu, 05 May 2011 07:43:59 +1000, Ben Finney wrote: ‘x’ is a name. Names are bound to values. Talk of “variable” only confuses the issue because of the baggage carried with that term. But to use 'name' as a complete replacement for 'variable', you have to stretch it to include things like a[

Re: seems like a bug in isinstance()

2011-05-07 Thread dmitrey
On May 7, 11:53 am, Gregory Ewing wrote: > Chris Rebert wrote: > > This is because you did `from Point import > > ...` in file2.py, whereas in file1.py you did `from > > openopt.kernel.Point import ...`. These 2 different ways of referring > > to the same module are sufficient to "trick"/"outsmart

Python3: imports don't see files from same directory?

2011-05-07 Thread dmitrey
hi all, I try to port my code to Python 3 and somehow files don't see files from same directory, so I have to add those directories explicitly, e.g. import sys sys.path += [...] Also, it leads to bugs like this one: http://groups.google.com/group/comp.lang.python/browse_thread/thread/961a90219a61e

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
John Nagle wrote: Such tuples are still identical, even if they contain identical references to immutable objects. The point is you'd have to do the comparison only one level deep, so it wouldn't be exactly the same as == on tuples. -- Greg -- http://mail.python.org/mailman/listinfo/pytho

Re: What other languages use the same data model as Python?

2011-05-07 Thread Chris Angelico
On Sat, May 7, 2011 at 7:21 PM, Gregory Ewing wrote: > Hans Georg Schaathun wrote: > >> You cannot reference nor manipulate a reference in python, and that IMHO >> makes them more abstract. > > You can manipulate them just fine by moving them > from one place to another: I think "manipulate" here

Re: What other languages use the same data model as Python?

2011-05-07 Thread Gregory Ewing
Hans Georg Schaathun wrote: You cannot reference nor manipulate a reference in python, and that IMHO makes them more abstract. You can manipulate them just fine by moving them from one place to another: a = b You can use them to get at stuff they refer to: a = b.c a[:] = b[:] You

Re: Dictionary Views -- good examples? [was Re: Python 3 dict question]

2011-05-07 Thread Gregory Ewing
Ethan Furman wrote: Ian Kelly wrote: next(iter(myDict.items())) Which is becoming less elegant. If you're doing this sort of thing a lot you can make a little helper function: def first(x): return next(iter(x)) then you get to say first(myDict.items()) -- Greg -- http://mail.pyt

Re: seems like a bug in isinstance()

2011-05-07 Thread Gregory Ewing
Chris Rebert wrote: This is because you did `from Point import ...` in file2.py, whereas in file1.py you did `from openopt.kernel.Point import ...`. These 2 different ways of referring to the same module are sufficient to "trick"/"outsmart" (C)Python and cause it to import the same module twice

Re: Coolest Python recipe of all time

2011-05-07 Thread Steven D'Aprano
On Fri, 06 May 2011 12:36:09 -0600, Ian Kelly wrote: > On Fri, May 6, 2011 at 10:59 AM, Steven D'Aprano > wrote: >> As written, amb is just a brute-force solver using more magic than is >> good for any code, but it's fun to play with. > > This isn't really amb; as you said it's just a brute-forc

Re: checking if a list is empty

2011-05-07 Thread Steven D'Aprano
On Fri, 06 May 2011 14:49:24 -0500, harrismh777 wrote: > Terry Reedy wrote: (2) if not li: >>> >>> This is fine. >> >> This is the intended way. Anything in addition is extra noise and >> wasted calculation. In other words, let Python do the boilerplate work >> for you. > > I agree, but

Re: PyGTK, Glade/libglade. What am I doing wrong?

2011-05-07 Thread Alister Ware
On Sat, 07 May 2011 15:14:07 +1100, Даниил Рыжков wrote: > Thanks, Cristian! It works. >> List of Pygtk: http://www.daa.com.au/mailman/listinfo/pygtk > Thanks again. Subscribed :) > 2011/5/7 craf : >> Hi. >> >> Try this: >> >> #!/usr/bin/env python >> >> import gtk.glade >> >> class TestPyGtk: >>

Re: string formatting

2011-05-07 Thread Terry Reedy
On 5/6/2011 8:09 PM, Chris Angelico wrote: On Sat, May 7, 2011 at 6:54 AM, Terry Reedy wrote: def emsg(x): if isinstance(x,tuple): x = (x,) print(The following object caused a proplem: %s" % x) Couldn't you just do that unconditionally? print(The following object caused a proplem: %s