Re: Proper place for everything
On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: > In article <[email protected]>, Steven > D'Aprano wrote: >>On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: >>> >>> Anybody know of the appropriate place to troll and flame about various >>> Python related issues? I'm kind of mad about some Python stuff and I >>> need a place to vent where people may or may not listen, but at at >>> least respond. Thought this would be a strange question, but I might >>> as well start somewhere. >> >>Thank you for your honesty, but trolling is not welcome. >> >>However if you have actual issues about Python, either pro or con, and >>hope to have a serious, respectful dialog where both parties listen to >>each other, feel free to raise them here. Keep in mind three things: [snip three things] > You forgot the fourth point. Apparently so did you :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
On Wednesday, September 5, 2012 10:41:19 PM UTC+8, Steven D'Aprano wrote: > On Wed, 05 Sep 2012 10:00:09 -0400, Dave Angel wrote: > > > > > On 09/05/2012 09:19 AM, Franck Ditter wrote: > > >> Thanks to all, but : > > >> - I should have said that I work with Python 3. Does that matter ? - > > >> May I reformulate the queston : "a is b" and "id(a) == id(b)" > > >> both mean : "a et b share the same physical address". Is that True ? > > >> Thanks, > > > > > > No, id() has nothing to do with physical address. The Python language > > > does not specify anything about physical addresses. Some > > > implementations may happen to use physical addresses, others arbitrary > > > integers. And they may reuse such integers, or not. Up to the > > > implementation. > > > > True. In principle, some day there might be a version of Python that runs > > on some exotic quantum computer where the very concept of "physical > > address" is meaningless. Or some sort of peptide or DNA computer, where > > the calculations are performed via molecular interactions rather than by > > flipping bits in fixed memory locations. > > > > But less exotically, Frank isn't entirely wrong. With current day > > computers, it is reasonable to say that any object has exactly one > > physical location at any time. In Jython, objects can move around; in > > CPython, they can't. But at any moment, any object has a specific > > location, and no other object can have that same location. Two objects > > cannot both be at the same memory address at the same time. > > > > So, for current day computers at least, it is reasonable to say that > > "a is b" implies that a and b are the same object at a single location. > > > > The second half of the question is more complex: > > > > "id(a) == id(b)" *only* implies that a and b are the same object at the > > same location if they exist at the same time. If they don't exist at the > > same time, then you can't conclude anything. > > > > > > > > -- > > Steven The function id(x) might not be implemented as an address in the user space. Do we need to distinguish archived objets and objects in the memory? -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
On 4/11/12 06:09:24, Aahz wrote:
> In article ,
> Chris Angelico wrote:
>> On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano
>> wrote:
>>>
>>> /* Shortcut for empty or interned objects */
>>> if (v == u) {
>>> Py_DECREF(u);
>>> Py_DECREF(v);
>>> return 0;
>>> }
>>> result = unicode_compare(u, v);
>>>
>>> where v and u are pointers to the unicode object.
>>
>> There's a shortcut if they're the same. There's no shortcut if they're
>> both interned and have different pointers, which is a guarantee that
>> they're distinct strings. They'll still be compared char-for-char
>> until there's a difference.
>
> Without looking at the code, I'm pretty sure there's a hash check first.
In 3.3, there is no such check.
It was recently proposed on python-dev to add such a check,
but AFAIK, no action was taken.
-- HansM
--
http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
/ [email protected] wrote on Fri 2.Nov'12 at 11:39:10 -0700 / > (I also hope I haven't just been suckered by a troll > attempt, windows/unix is better then unix/windows being > an age-old means of trolling.) No, i'm not a "troll". I was just adding my opinion to the thread, I assumed that was allowed. I didn't say UNIX is better than Windows, did I; I just feel that Windows is not -- for me anyway -- the most suitable plaform for learning about the science of computing and coding, etc... being a computer science student that's the view i have and share with those I learn with and from. Why must people be accused of trolling everytime they make a statement that conveys a preference over one platform or language, for example, than the other. Provoking someone by labeling them a troll or implying they might be is a bit childish really. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
In article <[email protected]>, Steven D'Aprano wrote: > On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: > > > In article <[email protected]>, Steven > > D'Aprano wrote: > >>On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: > >>> > >>> Anybody know of the appropriate place to troll and flame about various > >>> Python related issues? I'm kind of mad about some Python stuff and I > >>> need a place to vent where people may or may not listen, but at at > >>> least respond. Thought this would be a strange question, but I might > >>> as well start somewhere. > >> > >>Thank you for your honesty, but trolling is not welcome. > >> > >>However if you have actual issues about Python, either pro or con, and > >>hope to have a serious, respectful dialog where both parties listen to > >>each other, feel free to raise them here. Keep in mind three things: > > [snip three things] > > > You forgot the fourth point. > > Apparently so did you :) "Amongst the points are such diverse elements as..." -- http://mail.python.org/mailman/listinfo/python-list
surprising += for lists
Hi everybody! I was just smacked by some very surprising Python 2.7 behaviour. I was assembling some 2D points into a list: points = [] points += (3, 5) points += (4, 6) What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, 5, 4, 6]. My interpretations thereof is that the tuple (x, y) is iterable, so the elements are appended one after the other. Actually, I should have used points.append(), but that's a different issue. Now, what really struck me was the fact that [] + (3, 5) will give me a type error. Here I wonder why the augmented assignment behaves so much different. Can anyone help me understand this? Thanks! Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
Quick aside, you can insert tuples without much effort: `points += ((3,5),)` And also that I can't do the reverse, i.e.: >>> foo = tuple() >>> foo += [5,6] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple On Sun, Nov 4, 2012 at 10:57 PM, Ulrich Eckhardt wrote: > Hi everybody! > > I was just smacked by some very surprising Python 2.7 behaviour. I was > assembling some 2D points into a list: > > points = [] > points += (3, 5) > points += (4, 6) > > What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, > 5, 4, 6]. My interpretations thereof is that the tuple (x, y) is iterable, > so the elements are appended one after the other. Actually, I should have > used points.append(), but that's a different issue. > > Now, what really struck me was the fact that [] + (3, 5) will give me a > type error. Here I wonder why the augmented assignment behaves so much > different. > > Can anyone help me understand this? > > Thanks! > > Uli > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: who can give me some practical tutorials on django 1.4 or 1.5?
On Sun, 2012-11-04 at 13:29 +0800, Levi Nie wrote: > Who can give me some practical tutorials on django 1.4 or 1.5? > Thank you. Is the official[1] tutorial not practical enough? [1] https://docs.djangoproject.com/en/1.4/intro/tutorial01/ -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
On 11/04/2012 06:57 AM, Ulrich Eckhardt wrote: > Hi everybody! > > I was just smacked by some very surprising Python 2.7 behaviour. I was > assembling some 2D points into a list: > > points = [] > points += (3, 5) > points += (4, 6) > > What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, > 5, 4, 6]. mylist += is equivalent to mylist.extend. And as you say, what you wanted was append. > My interpretations thereof is that the tuple (x, y) is iterable, You're confusing cause and effect. If it weren't iterable, it'd be an error. It would NOT just somehow change to be equivalent to append. >>> points.extend(4) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable > so the elements are appended one after the other. Actually, I should have > used points.append(), but that's a different issue. > > Now, what really struck me was the fact that [] + (3, 5) will give me a > type error. Here I wonder why the augmented assignment behaves so much > different. What I wonder about is why list's __add__ is so fussy. > Can anyone help me understand this? > > Thanks! > > Uli > > I'd also point out that when using the extend() function call, we'd have to spell it: points.extend((3,5)) The extra parentheses are to make it clear to the compiler that this is a single argument, a tuple, and not two arguments. And similarly, points.append((3,5)) to get your original desired behavior. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
__unicode__() works, unicode() blows up.
Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an instance of this class by calling the constructor directly, self.username is None. When I pass that to unicode(), it blows up. However, calling __unicode__() directly, works as expected: >>> u = User() >>> print u.username None >>> print u.__unicode__() None >>> print unicode(u) Traceback (most recent call last): File "", line 1, in TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
In article , Roy Smith wrote: > >>> print u.__unicode__() > None > > >>> print unicode(u) > Traceback (most recent call last): > File "", line 1, in > TypeError: coercing to Unicode: need string or buffer, NoneType found > > What's going on here? I thought > (http://docs.python.org/2/library/functions.html#unicode) the latter two > calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. -- http://mail.python.org/mailman/listinfo/python-list
Missing modules compiling python3.3
I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel _dbm _gdbm _lzma _sqlite3 _tkinter readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. And also the "test_urlwithfrag" test fails, but when trying to do(as suggested in the README) "./python -m test -v test_urlwithfrag" I get an error[ImportError: No module named 'test.test_urlwithfrag' ] and when doing "./python -m test -v test_urllib2net" it skips the test saying it's normal on linux(then why make test runs it and it fails???) What am I missing? Should I install those modules manually? Is this expected? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Am 04.11.2012 15:42, schrieb Giacomo Alzetta: > I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are > missing. > > In particular when doing make test I get: > > Python build finished, but the necessary bits to build these modules were not > found: > _bz2 _curses_curses_panel > _dbm _gdbm _lzma > _sqlite3 _tkinter readline > To find the necessary bits, look in setup.py in detect_modules() for the > module's name. Hello Giacomo, your installation is lacking a couple of dependencies and header files. It's very easy to install the dependencies on Ubuntu: sudo apt-get build-dep python3.2 sudo apt-get install liblzma-dev HTH Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Giacomo Alzetta wrote: I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel You haven't installed the development headers for those modules giving errors. So for curses you'll need to install libncurses5-dev, lzma-dev etc. Sorry, I can't remember the package names as it's a while since I did this. Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up.
On 4 November 2012 13:32, Roy Smith wrote: > Environment: > Python-2.7.3 > Ubuntu Precise > mongoengine 0.6.20 > > I have a class which includes a __unicode__() method: > > class User(mongoengine.Document): > def __unicode__(self): > return self.username > > If I create an instance of this class by calling the constructor > directly, self.username is None. When I pass that to unicode(), it > blows up. However, calling __unicode__() directly, works as expected: > > >>> u = User() > >>> print u.username > None > > >>> print u.__unicode__() > None > > >>> print unicode(u) > Traceback (most recent call last): > File "", line 1, in > TypeError: coercing to Unicode: need string or buffer, NoneType found > > What's going on here? I thought > (http://docs.python.org/2/library/functions.html#unicode) the latter two > calls should be identical, but obviously they're not. >>> class Foo: ... def __unicode__(self): return "Bar" # NOT Unicode ... >>> Foo().__unicode__() 'Bar' >>> unicode(Foo()) u'Bar' unicode(x) calls x.__unicode__() *and then* coerces the result to Unicode. None cannot be coerced to Unicode. -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
In article , Roy Smith wrote: >In article , > Roy Smith wrote: >> >> >>> print u.__unicode__() >> None >> >> >>> print unicode(u) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: coercing to Unicode: need string or buffer, NoneType found >> >> What's going on here? I thought >> (http://docs.python.org/2/library/functions.html#unicode) the latter two >> calls should be identical, but obviously they're not. > >Why is it, that no matter how long you stare at a problem, the answer >comes to you moments after you hit the Post button? :-) > >The problem is that __unicode__() is supposed to return a Unicode >object, and unicode() enforces that. The fix is to change: > >def __unicode__(self): >return self.username > >to be: > >def __unicode__(self): >return unicode(self.username) > >This never got noticed before because normally, self.username already is >a unicode string, so it just works. You apparently need more coffee when programming after waking up! (Or even worse, staying up all night.) -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "Normal is what cuts off your sixth finger and your tail..." --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 04-Nov-2012 12:13, Jamie Paul Griffin wrote: / [email protected] wrote on Fri 2.Nov'12 at 11:39:10 -0700 / (I also hope I haven't just been suckered by a troll attempt, windows/unix is better then unix/windows being an age-old means of trolling.) No, i'm not a "troll". I was just adding my opinion to the thread, I assumed that was allowed. I didn't say UNIX is better than Windows, did I; I just feel that Windows is not -- for me anyway -- the most suitable plaform for learning about the science of computing and coding, etc... being a computer science student that's the view i have and share with those I learn with and from. Why must people be accused of trolling everytime they make a statement that conveys a preference over one platform or language, for example, than the other. Provoking someone by labeling them a troll or implying they might be is a bit childish really. Well stated Jamie --- I agree. I don't believe that all members of this list label you as a troll. --V -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
On 11/4/2012 7:45 AM, Dave Angel wrote: What I wonder about is why list's __add__ is so fussy. Guido's reason is that it is not clear what the types of [1,2] + (3,4), (1,2) + [3,4], [] + range(4), range(2) + [3,4], etcetera should be. Such mixtures may be bugs. Seq.__add__ exists to implement '+'. [].extend() will clearly be a list, and accepts any iterable. I believe the same logic is used for set operations. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
On 11/4/2012 8:41 AM, Roy Smith wrote: In article , Roy Smith wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File "", line 1, in TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. The same principle applies to some of the other special methods that sit behind builtin functions. >>> class C: def __len__(self): return '42' # whoops >>> len(C()) Traceback (most recent call last): File "", line 1, in len(C()) TypeError: 'str' object cannot be interpreted as an integer >>> class C: def __len__(self): return -42 # whoops again >>> len(C()) Traceback (most recent call last): File "", line 1, in len(C()) ValueError: __len__() should return >= 0 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: who can give me some practical tutorials on django 1.4 or 1.5?
On 11/4/2012 7:35 AM, Albert Hopkins wrote: On Sun, 2012-11-04 at 13:29 +0800, Levi Nie wrote: Who can give me some practical tutorials on django 1.4 or 1.5? Thank you. Is the official[1] tutorial not practical enough? [1] https://docs.djangoproject.com/en/1.4/intro/tutorial01/ There is also django-users list https://www.djangoproject.com/community/ -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
everyone on this list is troll On Sun, Nov 4, 2012 at 6:17 AM, Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > > > On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: > > > > > In article <[email protected]>, > Steven > > > D'Aprano wrote: > > >>On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: > > >>> > > >>> Anybody know of the appropriate place to troll and flame about > various > > >>> Python related issues? I'm kind of mad about some Python stuff and I > > >>> need a place to vent where people may or may not listen, but at at > > >>> least respond. Thought this would be a strange question, but I might > > >>> as well start somewhere. > > >> > > >>Thank you for your honesty, but trolling is not welcome. > > >> > > >>However if you have actual issues about Python, either pro or con, and > > >>hope to have a serious, respectful dialog where both parties listen to > > >>each other, feel free to raise them here. Keep in mind three things: > > > > [snip three things] > > > > > You forgot the fourth point. > > > > Apparently so did you :) > > "Amongst the points are such diverse elements as..." > -- > http://mail.python.org/mailman/listinfo/python-list > -- Cheers, Jeff Jeffries III CEO: www.willyoubemyfriend.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 01/11/2012 09:55, Jamie Paul Griffin wrote: / Robert Miles wrote on Wed 31.Oct'12 at 0:39:02 -0500 / For those of you running Linux: You may want to look into whether NoCeM is compatible with your newsreader and your version of Linux. It checks newsgroups news.lists.filters and alt.nocem.misc for lists of spam posts, and will automatically hide them for you. Not available for other operating systems, though, except possibly Unix. Anybody serious about programming should be using a form of UNIX/Linux if you ask me. It's inconceivable that these systems should be avoided if you're serious about Software Engineering and Computer Science, etc. For UNIX there are loads of decent news reading software and mail user agents to learn and use. slrn is a good one and point it at gmane.org as someone else pointed out. I can't even imagine using a browser or Google Groups, etc. now. Anybody serious about programming should know that an OS is a combination of the hardware and software. Can the *Nix variants now do proper clustering or are they still decades behind VMS? Never used the other main/mini frame systems myself but perhaps they are still vastly superior to this highly overrated *Nix crap. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Sun, Nov 4, 2012 at 11:39 AM, Mark Lawrence wrote: > Anybody serious about programming should know that an OS is a combination > of the hardware and software. Can the *Nix variants now do proper > clustering or are they still decades behind VMS? Never used the other > main/mini frame systems myself but perhaps they are still vastly superior > to this highly overrated *Nix crap. > What relevance does clustering have for a desktop workstation OS? -- http://mail.python.org/mailman/listinfo/python-list
Re: install pyOpenSSL in python2.7
On 2012-11-03, at 2:58 AM, 水静流深 wrote: i have install pyOpenSSL-0.11 in python2.7 this way: download pyOpenSSL-0.11.tar.gz #tar -zvxf pyOpenSSL-0.11.tar.gz #cd pyOpenSSL-0.11 #python setup.py install >>> import OpenSSL Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 45, in from OpenSSL import rand, SSL ImportError: /usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.so: undefined symbol: SSLv2_method how can i fix the problem? ImportError: /usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.so: undefined symbol: SSLv2_method -- http://mail.python.org/mailman/listinfo/python-list The pyOpenSSL home page at https://launchpad.net/pyopenssl says that the latest version is 0.11, but that is not true. The latest version is 0.13. You can get it on PyPI here http://pypi.python.org/pypi/pyOpenSSL SSLv2 is no longer supported in OpenSSL, and version 0.13 no longer expects it. - John -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Il giorno domenica 4 novembre 2012 15:56:03 UTC+1, mm0fmf ha scritto: > Giacomo Alzetta wrote: > > > I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are > > missing. > > > > > > In particular when doing make test I get: > > > > > > Python build finished, but the necessary bits to build these modules were > > not found: > > > _bz2 _curses_curses_panel > > > > You haven't installed the development headers for those modules giving > > errors. > > > > So for curses you'll need to install libncurses5-dev, lzma-dev etc. > > Sorry, I can't remember the package names as it's a while since I did this. > > > > Andy That's right! Sorry, but I thought I installed those some months ago for an other python installation, but probably I've also removed them :s The "test_urlwithfrag" is still failing though. -- http://mail.python.org/mailman/listinfo/python-list
PDFBuilder can now take multiple input files from command line
Here is the blog post about it: http://jugad2.blogspot.in/2012/11/pdfbuilder-can-now-take-multiple-input.html In short: removed the temporary hard-coding, refactored the code some. PDFBuilder can now use multiple input files (of type .csv / .tdv), specified on the command-line, to create a composite PDF from those inputs. .tdv = Tab Delimited Values, such as commonly used in UNIX tools like sed / grep / awk and friends. - Vasudev Ram www.dancingbison.com -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On Thursday, March 24, 2011 10:32:44 AM UTC-4, Kees Bakker wrote: > Hi, > > Sad news (for me, at least), in the upcoming version 7.0 of NetBeans > there will be no Python plugin anymore. > > I have been using NetBeans for Python development for a while now > and I was very happy with it. > > See this archive for details: > http://netbeans.org/projects/www/lists/nbpython-dev/archive/2010-11/message/0 > http://netbeans.org/projects/www/lists/nbpython-dev/archive/2011-01/message/0 > -- > Kees It is sad indeed. I would have preferred to use netbeans for all my coding and now I have to use both netbeans and a python IDE. I have been using PyCharm for a year now and I am very happy with it. It is the best I have used for python development with django, html, javascript and css support as well. I recommend trying it out. However I am not happy about having to use different IDEs as I find myself coding in both python and php from project to project. Jetbrains IDEA Ultimate edition has both php and python support but is way out of my budget. -- http://mail.python.org/mailman/listinfo/python-list
Web application for drawing directed graphs from the output of Python's cProfile
I recently built startgraphi.com. It's a web application that draws directed graphs of running times and function calls from the output of Python's cProfile. It also creates a sortable table of running times and function calls. I hope someone finds it useful. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Nov 4, 4:14 pm, Jamie Paul Griffin wrote: > / [email protected] wrote on Fri 2.Nov'12 at 11:39:10 -0700 / > > > (I also hope I haven't just been suckered by a troll > > attempt, windows/unix is better then unix/windows being > > an age-old means of trolling.) > > No, i'm not a "troll". I was just adding my opinion to the thread, I assumed > that was allowed. I didn't say UNIX is better than Windows, did I; I just > feel that Windows is not -- for me anyway -- the most suitable plaform for > learning about the science of computing and coding, etc... being a computer > science student that's the view i have and share with those I learn with and > from. Why must people be accused of trolling everytime they make a statement > that conveys a preference over one platform or language, for example, than > the other. Provoking someone by labeling them a troll or implying they might > be is a bit childish really. Hi Jamie Among people who know me, I am a linux nerd: My sister scolded me yesterday because I put files on her computer without spaces: DoesAnyoneWriteLikeThis?!?! Your post reminds me: As someone who has taught CS for 25 years, Ive not only been party to his Unix-fanboy viewpoint but have even actively fostered it. Over time Ive come to have some pangs of conscience about this. Evidently this kind of attitude has helped no one: not my students, not the corporations they join, not the society at large. So now, on my blog I maintain a record of the foibles of CS academics. http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-1.html is a history of CS as it is normally given. http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-2.html is the above deconstructed with stupidities of academic CS factored in. -- http://mail.python.org/mailman/listinfo/python-list
Multi-dimensional list initialization
So, here I was thinking "oh, this is a nice, easy way to initialize a 4D matrix" (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] (Obviously, I could have just hardcoded the initialization, but I'm too lazy to type all that out ;)) The behaviour I encountered seems a little contradictory to me. [None] * 4 creates four distinct elements in a single array while [[None] * 4] * 4 creates one distinct array of four distinct elements, with three references to it: >>> a = [None] * 4 >>> a[0] = 'a' >>> a ['a', None, None, None] >>> m = [[None] * 4] * 4 >>> m[0][0] = 'm' >>> m [['m', None, None, None], ['m', None, None, None], ['m', None, None, None], ['m', None, None, None]] Is this expected behaviour and if so, why? In my mind either result makes sense, but the inconsistency is what throws me off. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On 2012-11-04, at 4:45 PM, [email protected] wrote: > However I am not happy about having to use different IDEs as I find myself > coding in both python and php from project to project. One of the many reasons Vim is my editor of choice. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Mon, Nov 5, 2012 at 5:10 PM, rusi wrote: > Among people who know me, I am a linux nerd: My sister scolded me > yesterday because I put files on her computer without spaces: > DoesAnyoneWriteLikeThis?!?! My filenames seldom have spaces in them, but that has nothing to do with how I write English. Names are names. They're not essays, they are not written as full sentences. When a name contains spaces, it must be delimited (or the space must be escaped, if your environment permits) any time it occurs inside some other context - most commonly, as a command-line argument. Back when I was using MS-DOS 5, it was possible to have file names with spaces. It wasn't easy to manipulate them from the command line, but you could reference them using globs (eg replace the space(s) with ? and hope that there are no false hits). OS/2, when working on a FAT filesystem, would create files called "EA DATA. SF" or "WP ROOT. SF" or "WP SHARE. SF" (two spaces in each), and most DOS/Windows programs wouldn't (couldn't) touch them - they were safe repositories for system metadata (on smarter filesystems, that sort of thing would be stored as file attributes, not as separate files). It's nothing to do with operating system. File names are names, and spaces in them are seldom worth the hassle unless you manipulate those files solely using a GUI. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On 11/04/2012 10:27 PM, Demian Brecht wrote: So, here I was thinking "oh, this is a nice, easy way to initialize a 4D matrix" (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] FYI: The behavior is the same in python 3.2 m=[[None]*4]*4 produces a nested list with all references being to the first instance of the inner list construction. I agree, the result is very counter-intuitive; hmmm... but I think you meant: m = [[None] * 4, [None] * 4, [None] * 4, [None] *4 ] rather than: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] ? :) ? I asked a why question on another thread, and watched several dodges to the main question; I'll be watching to see if you get anything other than "That's the way it's defined in the API". IMHO -- that's not a real answer. My guess is that the original implementation never considered anything beyond a 1d list. :) A more precise related question might be: is there a way to force the replication operator to use copying rather than referencing? :/ -- http://mail.python.org/mailman/listinfo/python-list
python destructor
Hello there folks, I have a bit of a special issue. I'll start by disclosing myself for what i am doing. I am a postgraduate student and I really have good reasons to do what I am doing. At least i think so. And not the issue. I am building a python web service. This web service has some generic objects and I use a metaclass to customize the classes. Second I use a non-conventional object oriented database, dybase (http://www.garret.ru/dybase/doc/dybase.html#introduction) Now these is a OODBMS claiming to support ACID transactions. The instances of my objects are recursively organizing themselves into a hierarchical tree-like structure. When I make an instance of this object persistent dybase actually can recursively save all tree structure. Everything works well here. I altered the main class situated at the root of my class hierarchy to actually store inside the__dict__ not the instances of its children but their unique ID's. Then when I set a child attribute I create it and instead of being stored in the instance the child goes to a database index object. Thus it becomes Universally addressable. The a parent retrieves the child it actually fetches it from the database. In this way I ended up with very small objects.However these objects can regenerate the treelike structure as if they were storing there children in the __dict__. The issue is how to give the instances access to the database and properly handle the opening and closing of the database. It seems futile to me to actually open/close the connection through a context. Because the database is a file it will issue an IO operation on every attribute access and we all know __getattribute__ is used extremely often. For this reason I thought the best way would be to wrap the dybase Storage (main class) into a local storage version which would have __del__ method. The local Storage is a new style class..it opens the DB file but the __del__ is never called. This is because the Storage class has at least 2 cyclic references. So my Storage class never closes the database. I would like this class to close the database when it is garbage collected. The class is a Singleton FYI as well but this might not be relevant or even necessary. So my question is: what s the best way to force __del__ on a singleton that has cyclic references. Should i use weakref and alter the original source? Is there a way i can force a singleton to garbage collect itself?. I am by no means a software engineer so i would appreciate any advice from some experts on the matter. Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On Sun, Nov 4, 2012 at 10:27 PM, Demian Brecht wrote: > So, here I was thinking "oh, this is a nice, easy way to initialize a 4D > matrix" (running 2.7.3, non-core libs not allowed): > > m = [[None] * 4] * 4 > > The way to get what I was after was: > > m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] > > (Obviously, I could have just hardcoded the initialization, but I'm too lazy > to type all that out ;)) > > The behaviour I encountered seems a little contradictory to me. > [None] * 4 creates four distinct elements in a single array > while [[None] * 4] * 4 creates one distinct array of four distinct elements, > with three references to it: Incorrect. In /both/ cases, the result is a list of length 4, whose elements are 4 (references to) the exact same object as the original list's element. Put simply, the list multiplication operator never copies objects; it just makes additional references to them. However, unlike a list object (as in your latter example), the object `None` is completely immutable (and what's more, a singleton value), so you just-so-happen *not to be able to* run into the same problem of mutating an object (assignment to an index of a list constitutes mutation of that list) that is referenced in multiple places, for you cannot mutate None in the first place!: >>> x = None >>> x.a = 42 Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'a' >>> # it doesn't overload any mutating operators: >>> type(None).__dict__.keys() ['__hash__', '__repr__', '__doc__'] >>> # and it obviously has no instance variables, >>> # so, we can't modify it in any way whatsoever! (Lists, on the other hand, define item assignment, .pop(), .remove(), and a few other mutator methods.) a = [None] * 4 a[0] = 'a' a > ['a', None, None, None] > m = [[None] * 4] * 4 m[0][0] = 'm' m > [['m', None, None, None], ['m', None, None, None], ['m', None, None, None], > ['m', None, None, None]] > > Is this expected behavior Yes. It's also a FAQ: http://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list > and if so, why? It's a general (albeit AFAIK unstated) principle that Python never copies objects unless you explicitly ask it to. You have encountered one example of this rule in action. > In my mind either result makes sense, but the inconsistency is what throws me > off. It is perfectly consistent, once you understand what list multiplication actually does. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: x = None x.a = 42 > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingMeError for times when you do something utterly insane like this. Attributes of None??!? :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] sys.py3k
On Mon, Nov 5, 2012 at 9:33 AM, Steven D'Aprano wrote: > On 05/11/12 08:49, anatoly techtonik wrote: >> >> if sys.py3k: >># some py2k specific code >>pass > > # Bring back reload in Python 3. > try: > reload > except NameError: > from imp import reload > > try: > any > except NameError: > # Python 2.4 compatibility. > def any(items): > for item in items: > if item: > return True > return False Take the best of both worlds: try: # py3k reload except NameError: from imp import reload Now you can grep your code for py3k without changing the language! Never underestimate the value of comment tokens. Universal ones like TODO or private ones like NULLSAFE, all it takes is grep or your editor's Find function to make them all obvious. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On Mon, Nov 5, 2012 at 5:29 PM, Demian Brecht wrote: > > On 2012-11-04, at 4:45 PM, [email protected] wrote: >> However I am not happy about having to use different IDEs as I find myself >> coding in both python and php from project to project. > > One of the many reasons Vim is my editor of choice. Same here. My IDE needs are very simple. Give me an editor that lets me manipulate multiple files at once, can one-key invoke make, and preferably has syntax highlighting, and I'm happy. So for me, SciTE is my editor and IDE. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Nov 5, 11:40 am, Chris Angelico wrote: > On Mon, Nov 5, 2012 at 5:10 PM, rusi wrote: > > Among people who know me, I am a linux nerd: My sister scolded me > > yesterday because I put files on her computer without spaces: > > DoesAnyoneWriteLikeThis?!?! > > My filenames seldom have spaces in them, but that has nothing to do > with how I write English. Names are names. They're not essays, they > are not written as full sentences. When a name contains spaces, it > must be delimited (or the space must be escaped, if your environment > permits) any time it occurs inside some other context - most commonly, > as a command-line argument. > > Back when I was using MS-DOS 5, it was possible to have file names > with spaces. It wasn't easy to manipulate them from the command line, > but you could reference them using globs (eg replace the space(s) with > ? and hope that there are no false hits). OS/2, when working on a FAT > filesystem, would create files called "EA DATA. SF" or "WP ROOT. SF" > or "WP SHARE. SF" (two spaces in each), and most DOS/Windows programs > wouldn't (couldn't) touch them - they were safe repositories for > system metadata (on smarter filesystems, that sort of thing would be > stored as file attributes, not as separate files). > > It's nothing to do with operating system. File names are names, and > spaces in them are seldom worth the hassle unless you manipulate those > files solely using a GUI. > > ChrisA So you and I (and probably many on this list) agree! -- http://mail.python.org/mailman/listinfo/python-list
Re: Applying a paid third party ssl certificate
[email protected] writes: > I haven't quite figured out how to apply a paid ssl cert, say RapidSSL free > SSL test from Python's recent sponsor sslmatrix.com and what to do with that > to make Python happy. > > This good fellow suggests using the PEM format. I tried and failed. > http://www.minnmyatsoe.com/category/python-2/ > > The self signed cert recepies found all work swell, but some browsers > (webkit) gets very upset indeed. I want to use ajax requests from clients > (e.g autocompletion, stats collection etc) and put that in a python program > without hogging down the main apache stack, but without a proper ssl cert > this doesn't work. > > Does anyone have any ideas what to do? >From your description, I derive that you want your client (python program) to autenticate itself via an SSL certificate. If my assumption is correct, I would start with a look at the Python documentation for HTTPS connections. When I remember right, they have 2 optional parameters to specify a client certificate and to specify trusted certificates (when server presented certificates should be verified). Once, you have determined how to present the client certificate for the base HTTPS connection, you may need to look at the documentation or source code of higher level apis (such as "urllib2") to learn how to pass on your certificate down to the real connection. You may also have a look at "PyPI". You may find there packages facilitating Python's "SSL" support. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On 11/04/2012 11:27 PM, Chris Angelico wrote: On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert wrote: x = None x.a = 42 Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingMeError for times when you do something utterly insane like this. Attributes of None??!? :) ChrisA Hmmm? Everything in Python is an object. Therefore! SURE. None *does* have attributes! ( even if not useful ones... ) eg: " None.__getattribute__( "__doc__" ) " doesn't produce an error. In C, in Linux, at the end of the file "errno.h", where all error codes are listed eg:( EIO, EAGAIN, EBUSY, E) They had a final error like the one you dreamed up, it was called "EIEIO"; and the comment read something like, "All the way around Elmer's barn". :) The poster just hit that strange wall -- *all* built in types are injection proof; and that property is both good and bad... -- http://mail.python.org/mailman/listinfo/python-list
