[ANN] Leipzig Python User Group - Meeting, December 1, 2009, 08:00pm

2009-11-29 Thread Stefan Schwarzer
=== Leipzig Python User Group === We will meet on Tuesday, December 1 at 8:00 pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Food and soft drinks are provided. Please send a short confirmation mail to i...@python-academy.de, so

Re: Feature request: String-inferred names

2009-11-29 Thread The Music Guy
On Sat, Nov 28, 2009 at 9:39 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Removing code redundancy is all very well, but beware of turning into an architecture astronaut: http://www.joelonsoftware.com/articles/fog18.html There is such a thing as

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread n00m
My Py solution: = import psyco psyco.full() def foo(s): n = len(s) s = s + ' ' a = [[] for i in xrange(128)] ans = 0 for i in xrange(n - 1, -1, -1): lev = 0 for st in xrange(len(a[ord(s[i])]) - 1, -1, -1):

Re: slightly OT: Python BootCamp

2009-11-29 Thread Carl Banks
On Nov 28, 6:15 pm, J dreadpiratej...@gmail.com wrote: Ok... so I've been re-teaching myself python, as it's been several years since I last really used it.  And in the midst of this, my contracting company came up to me on Friday and asked if I'd be interested in filling a last minute vacancy

Re: slightly OT: Python BootCamp

2009-11-29 Thread J
On Sun, Nov 29, 2009 at 03:57, Carl Banks pavlovevide...@gmail.com wrote: On Nov 28, 6:15 pm, J dreadpiratej...@gmail.com wrote: http://www.otg-nc.com/python-bootcamp It's a week long Python Bootcamp. I'm surprised they're able to fill out 5 days with intensive training on Python. :)

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread n00m
This worked out in 5.28s Imo it's not that *much* slower (of course, Psyco can't help here) === import itertools def subs(s): return len(set(itertools.chain( s[i:j] for i in xrange(len(s)) for j in xrange(i, len(s)+1 - 1 from time

Re: Filling in a tuple from unknown size list

2009-11-29 Thread inhahe
maybe that thing in python 3 that someone mentioned is the answer, but otherwise i always think Python should admit something like this: a, b, c, *d = list i.e. if list were [1,2,3,4,5], you'd get a=1, b=2, c=3, d=[4, 5] not that that solves the None problem, though i don't have any feature

Re: Filling in a tuple from unknown size list

2009-11-29 Thread inhahe
On Sun, Nov 29, 2009 at 4:42 AM, inhahe inh...@gmail.com wrote: maybe that thing in python 3 that someone mentioned is the answer, but otherwise i always think Python should admit something like this: a, b, c, *d = list i.e. if list were [1,2,3,4,5], you'd get a=1, b=2, c=3, d=[4, 5] not

Re: Feature request: String-inferred names

2009-11-29 Thread The Music Guy
Okay, I'm having a really hard time telling which messages are getting on to the list and which ones aren't. Some of the messages I send show up in the comp.lang.python mirror in Google Groups, and some aren't. Others show up on the Groups mirror, but don't show up in Gmail, or show up in a

Simple greatest common factor script

2009-11-29 Thread fejky
Simple script that calculates greatest common factor using euclid's theorem. a = int(input(Enter a: )) b = int(input(Enter b: )) m = 1 while True: if m != 0: if b a: n = b/a m = b % a print b, : , a, = , n, i ost , m b = m

Re: Simple greatest common factor script

2009-11-29 Thread Patrick Sabin
I don't see how this script is able to divide by zero. If a and b switch places everything works ok. Have a look at your if-statements. It is possible, that both your if's are executed in one loop iteration (you can check this using pdb). You may want to try elif instead. - Patrick --

Re: Simple greatest common factor script

2009-11-29 Thread fejky
I have no idea how i missed that. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-11-29 Thread inhahe
On Sun, Nov 29, 2009 at 5:15 AM, The Music Guy fearsomedragon...@gmail.comwrote: Okay, I'm having a really hard time telling which messages are getting on to the list and which ones aren't. Some of the messages I send show up in the comp.lang.python mirror in Google Groups, and some aren't.

Re: Arcane question regarding white space, editors, and code collapsing

2009-11-29 Thread inhahe
I had this same problem with an application called Notepad++, which is a shame because I like the way it works and it's nice and tight. Now I use Komodo Edit instead, which doesn't have that problem, and has all the features of Notepad++ but just isn't as fast. Also all the colors were awful,

Re: debugger on system with Python 2 and 3

2009-11-29 Thread Yo Sato
Thanx Alan, I am using Fedora Core 11. I wanted to use emacs, rather than the full-blown IDE or entirely gui-based debugger, and that's why I was drawn to pydb in the first instance. If there's no other choice I don't mind using winpdb, but it is installed (through Yum) under Python2 library and

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread Bearophile
n00m: This worked out in 5.28s Imo it's not that *much* slower (of course, Psyco can't help here) There's no need of a chain here, so you can rewrite this: import itertools def subs(s): return len(set(itertools.chain( s[i:j] for i in xrange(len(s)) for j in

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread Bearophile
n00m: My Py solution: ... Cute. You can replace: a[ord(s[i])] += [i] With: a[ord(s[i])].append(i) If you want to micro-optimize this with Psyco may be a little faster: (lev 1) Than: lev // 2 But to increase speed it's usually better to reduce memory allocations. So you can try to find a way

mysqldb cursor returning type along with result ?

2009-11-29 Thread Paul O'Sullivan
Just taken to Python (2.5)and started to look at some DB cursor stuff using MySQL. Anyway, after creating a query that in MySQL that has a result set of decimals I find that the cursor in python after a fetchall() returns a tuple that contains the following :: ((Decimal(101.10),),

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread Bearophile
n00m: my home tests proved Python is a fellow fast beast of C++. Quite unexpected (I expected Py would be by ~10 times slower). PS Both my codes are identical in their algorithms. = 0.016         0.0150001049042   --- exec times Maybe in your C++ code there's

staticmethod not callable? (trying to make a Singleton metaclass..)

2009-11-29 Thread inhahe
I'm trying to come up with a system for singletons, where I don't have to modify anything for an individual class except to define __metaclass__ or, if possible, to inherit another class. I want it to raise an error if making a duplicate instance of a class is attempted, rather than to return the

Re: mysqldb cursor returning type along with result ?

2009-11-29 Thread Tim Chase
((Decimal(101.10),), (Decimal(99.32),), (Decimal(97.95),), (Decimal(98.45),), (Decimal(97.39),), (Decimal(97.91),), (Decimal (98.08),), (Decimal(97.73),)) as such : sum(result) fails with TypeError: unsupported operand type(s) for +: 'int' and 'tuple' How do I either get the resultset back as

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread n00m
On Nov 29, 3:15 pm, Bearophile bearophileh...@lycos.com wrote: Maybe in your C++ code there's something that can be improved, this is a 1:1 translation to D (V.1) language (using dlibs) and it's about 2.2 times faster than the Psyco version:http://codepad.org/MQLj0ydB Using a smarter usage of

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread n00m
http://en.wikipedia.org/wiki/Suffix_tree Looks not very friendly appealing :-) -- http://mail.python.org/mailman/listinfo/python-list

* for generic unpacking and not just for arguments?

2009-11-29 Thread Russell Warren
Is there a reason that this is fine: def f(a,b,c): ... return a+b+c ... f(1, *(2,3)) 6 but the code below is not? x = (3, 4) (1, 2, *x) == (1, 2, 3, 4) Traceback (most recent call last): File string, line 1, in fragment invalid syntax: string, line 1, pos 8 Why does it only work when

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread inhahe
On Sun, Nov 29, 2009 at 9:10 AM, n00m n...@narod.ru wrote: Even if Py by 4x *slower* -- it's still a perfect Ok for it (C# will be much (much) slower than Python). How do you figure? As far as I know C# is many, many times faster than Python. (i was disappointed to find out that even

Re: Feature request: String-inferred names

2009-11-29 Thread David Robinow
On Sun, Nov 29, 2009 at 6:58 AM, inhahe inh...@gmail.com wrote: Did you say you were using gmail to post?  I think mailing lists tend to have issues with gmail because it puts html in the message or something like that.  Btw I recently set up this mailing list to send me a message back when I

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Mel
Russell Warren wrote: Maybe it's just that * is strictly for arguments, and trying it for generic tuple unpacking is abuse (which is down the corridor in 12A). I'd agree with that. It's a feature of function calls, not a feature of sequence types, so that you can handle a set of function

Re: python setup.py build 32-bits on x86_64 machine

2009-11-29 Thread Aahz
In article 4b08d6e9$0$28097$a729d...@news.telepac.pt, =?UTF-8?B?U8Opcmdpbw==?= Monteiro Basto sergi...@sapo.pt wrote: I am in x86_64 arch , but I need compile things on 32 bits. python setup.py build Googling for linux force 32-bit build and similar phrases should find some useful results. --

Re: string payload expected: type 'list' error

2009-11-29 Thread Lie Ryan
On 11/27/2009 8:43 PM, Ramdas wrote: I tried with MIMEBASE but it still fails.. I changed it to MIMEText, hoping that might trick __handletext to think its a string Anyway that also doesn't work. just pass the string directly to MIMEBase.set_payload: fp = open('...') msg1 =

Re: xmlrpc idea for getting around the GIL

2009-11-29 Thread Aahz
In article 4b0b07a1$0$22159$9b622...@news.freenet.de, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= mar...@v.loewis.de wrote: In any case, I don't think you'll need a multi-process solution; a single-process multi-threading approach will do fine. Just create *another* thread, that runs at a low

Re: slightly OT: Python BootCamp

2009-11-29 Thread Steve Howell
On Nov 28, 6:15 pm, J dreadpiratej...@gmail.com wrote: Ok... so I've been re-teaching myself python, as it's been several years since I last really used it.  And in the midst of this, my contracting company came up to me on Friday and asked if I'd be interested in filling a last minute vacancy

Re: mysqldb cursor returning type along with result ?

2009-11-29 Thread Lie Ryan
On 11/30/2009 12:14 AM, Paul O'Sullivan wrote: Just taken to Python (2.5)and started to look at some DB cursor stuff using MySQL. Anyway, after creating a query that in MySQL that has a result set of decimals I find that the cursor in python after a fetchall() returns a tuple that contains the

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread n00m
Tested both my codes against a random string of length = 1. === from random import choice s = '' for i in xrange(1): s += choice(('a','b','c','d','e','f')) === C++: ~0.28s Python: ~0.48s PS I suspect

Re: slightly OT: Python BootCamp

2009-11-29 Thread Aahz
In article mailman.1091.1259486627.2873.python-l...@python.org, J dreadpiratej...@gmail.com wrote: On Sun, Nov 29, 2009 at 03:57, Carl Banks pavlovevide...@gmail.com wrote: On Nov 28, 6:15=A0pm, J dreadpiratej...@gmail.com wrote: http://www.otg-nc.com/python-bootcamp It's a week long Python

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread inhahe
On Sun, Nov 29, 2009 at 10:40 AM, Mel mwil...@the-wire.com wrote: Russell Warren wrote: Maybe it's just that * is strictly for arguments, and trying it for generic tuple unpacking is abuse (which is down the corridor in 12A). I'd agree with that.  It's a feature of function calls, not a

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Christian Heimes
Russell Warren wrote: but the code below is not? x = (3, 4) (1, 2, *x) == (1, 2, 3, 4) Traceback (most recent call last): File string, line 1, in fragment invalid syntax: string, line 1, pos 8 Why does it only work when unpacking arguments for a function? Is it because the code

Re: Implementation of Book Organization tool (Python2.[x])

2009-11-29 Thread Aahz
In article 4b0a06b...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: Python dictionary is stored in memory and closing the program == deleting the database. You can pickle dictionary; and this might be sufficient for quick and dirty, low-volume purpose. Pickled dictionary is the least

Re: Best strategy for overcoming excessive gethostbyname timeout.

2009-11-29 Thread r0g
r0g wrote: r0g wrote: Gabriel Genellina wrote: En Fri, 27 Nov 2009 22:35:36 -0300, r0g aioe@technicalbloke.com escribió: gethostbyname ignores setdefaulttimeout. How big a job is it to use non-blocking sockets to write a DNS lookup function with a customisable timeout? A few lines? A

Auto net surfing

2009-11-29 Thread joao abrantes
How can I make a python program that votes on certain polls ? Atm I am using ClientForm to fill forms but the polls that I found are always of the type = hidden and I don't know how to do it. I would also want to do a python program that would vote on a website. For example, if I go to this url

[ANNC] pybotwar-0.7

2009-11-29 Thread Lee Harr
pybotwar is a fun and educational game where players write computer programs to control simulated robots. http://pybotwar.googlecode.com/ pybotwar uses pybox2d for the physical simulation. It can be run in text-only mode -- useful for longer tournaments -- or use pyqt or pygame for a graphical

Re: staticmethod not callable? (trying to make a Singleton metaclass..)

2009-11-29 Thread Gabriel Genellina
En Sun, 29 Nov 2009 10:25:21 -0300, inhahe inh...@gmail.com escribió: I'm trying to come up with a system for singletons, where I don't have to modify anything for an individual class except to define __metaclass__ or, if possible, to inherit another class. I want it to raise an error if

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Russell Warren
On Nov 29, 11:09 am, Christian Heimes li...@cheimes.de wrote: The feature is available in Python 3.x: a, b, *c = 1, 2, 3, 4, 5 a, b, c (1, 2, [3, 4, 5]) a, *b, c = 1, 2, 3, 4, 5 a, b, c (1, [2, 3, 4], 5) Interesting... especially the recognition of how both ends work with the a, *b,

Installing Python 2.5 with Python 2.6

2009-11-29 Thread pranav
Hi, I used to develop applications on Google AppEngine SDK (which supports Python 2.5) on my Fedora 10. I upgraded to Fedora 12 recently and it has Python 2.6. Unfortunately, some things are breaking up with the SDK. Here is the trace http://dpaste.com/hold/126668/ I had been suggested by the

delete column content

2009-11-29 Thread Francesco Pietra
Hi: How to replace with blank the single-character in column 21 of a pdb file (in pdb numbering it is column 22). Attached is an incomplete exercise with slices. I am unable to get real plain text with gmail. Thanks for help francesco pietra # Sample line # Slice indexes cut to the left of the

Re: Filling in a tuple from unknown size list

2009-11-29 Thread Ned Deily
In article da776a8c0911290142o8ddce42n4825188bc5e23...@mail.gmail.com, inhahe inh...@gmail.com wrote: maybe that thing in python 3 that someone mentioned is the answer, but otherwise i always think Python should admit something like this: a, b, c, *d = list i.e. if list were [1,2,3,4,5],

Re: delete column content

2009-11-29 Thread Diez B. Roggisch
Francesco Pietra schrieb: Hi: How to replace with blank the single-character in column 21 of a pdb file (in pdb numbering it is column 22). Attached is an incomplete exercise with slices. I am unable to get real plain text with gmail. Thanks for help Wasn't the help you already got a few days

Re: Installing Python 2.5 with Python 2.6

2009-11-29 Thread pranav
On Nov 29, 11:06 pm, pranav pra...@gmail.com wrote: Hi, I used to develop applications on Google AppEngine SDK (which supports Python 2.5) on my Fedora 10. I upgraded to Fedora 12 recently and it has Python 2.6. Unfortunately, some things are breaking up with the SDK. Here is the

Re: delete column content

2009-11-29 Thread Vlastimil Brom
2009/11/29 Francesco Pietra francesco.pie...@accademialucchese.it: Hi: How to replace with blank the single-character in column 21 of a pdb file (in pdb numbering it is column 22). Attached is an incomplete exercise with slices. I am unable to get real plain text with gmail. Thanks for help

Re: debugger on system with Python 2 and 3

2009-11-29 Thread Nir
rpdb2 should be compatible with Python 3.x. And once you start a debugging session with rpdb2 (running with Python 3.x) you can attach to it from a winpdb instance (running with Python 2.x) On Nov 29, 2:29 pm, Yo Sato yosat...@gmail.com wrote: If there's no other choice I don't mind using

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Lie Ryan
On 11/30/2009 1:25 AM, Russell Warren wrote: Maybe it's just that * is strictly for arguments, and trying it for generic tuple unpacking is abuse (which is down the corridor in 12A). Because (1, 2, *x) == (1, 2, 3, 4) is not tuple unpacking [!] Tuple unpacking is related with assignment,

teaching python using turtle module

2009-11-29 Thread Brian Blais
Hello, I was just playing with the turtle module, and thought it was an interesting way to augment the introduction to python (I teach college students, who haven't had any programming). It's a great way to introduce functions, for-loops, and general program structures. After a bit of

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Tim Chase
The feature is available in Python 3.x: a, b, *c = 1, 2, 3, 4, 5 a, b, c (1, 2, [3, 4, 5]) a, *b, c = 1, 2, 3, 4, 5 a, b, c (1, [2, 3, 4], 5) This is a nice feature of 3.x but I'm disappointed (especially in light of the move to make more things iterators/generators), that the first form

Exec Statement Question

2009-11-29 Thread Victor Subervi
Hi; I have the following line of code: exec('%s()' % table) where 'table' is a variable in a for loop that calls variables from another script. I've made it so that it only calls one variable. I know for a fact that it's calling that variable in the script because it found errors in that script.

Re: Creating a local variable scope.

2009-11-29 Thread markolopa
Hi, On 18 Sep, 10:36, markol...@gmail.com markol...@gmail.com wrote: On Sep 11, 7:36 pm, Johan Grönqvist johan.gronqv...@gmail.com wrote: I find several places in my code where I would like tohavea variable scope that is smaller than the enclosing function/class/module definition. This is

Re: Number of distinct substrings of a string [continuation]

2009-11-29 Thread Bearophile
n00m: I suspect that building of Suffix Tree would be a big exec.time-consuming overhead In C/D/C++ there are ways to allocate memory in smarter ways, using pools, arenas, stacks, freelists, etc. With that, using a compact encoding of tree nodes (there are many different tricks to reduce space

Re: Variables with cross-module usage

2009-11-29 Thread Nitin Changlani.
Thanks Dennis and Steve, This explains it all! I will discard using one.a and use one.myList[0] directly, instead. I really appreciate your patience and the elaboration of the concept. Warm Regards, Nitin Changlani. On Sun, Nov 29, 2009 at 1:02 AM, Steven D'Aprano

Re: Creating a local variable scope.

2009-11-29 Thread Lie Ryan
On 11/30/2009 8:12 AM, markolopa wrote: Hi, On 18 Sep, 10:36, markol...@gmail.commarkol...@gmail.com wrote: On Sep 11, 7:36 pm, Johan Grönqvistjohan.gronqv...@gmail.com wrote: I find several places in my code where I would like tohavea variable scope that is smaller than the enclosing

Re: [Edu-sig] teaching python using turtle module

2009-11-29 Thread Edward Cherlin
On Sun, Nov 29, 2009 at 11:34, Brian Blais bbl...@bryant.edu wrote: Hello, I was just playing with the turtle module, and thought it was an interesting way to augment the introduction to python (I teach college students, who haven't had any programming).  It's a great way to introduce

Re: [Edu-sig] teaching python using turtle module

2009-11-29 Thread Brian Blais
On Nov 29, 2009, at 17:51 , Edward Cherlin wrote: If you use the Python-programmable tile in Turtle Art in Sugar, or Smalltalk in the Turtle Graphics in Etoys, it's even better. I'll have to check this out. sequences, where I can use a conditional to stop when the turtle would go off the

Re: Creating a local variable scope.

2009-11-29 Thread markolopa
Hi Lie! On Nov 29, 11:11 pm, Lie Ryan lie.1...@gmail.com wrote: here is another bug you might have if python have an even-more-local scope: while True:      s = raw_input(enter something: )      if s not in ('q', 'quit', 'exit'): break print s if the while block has become its own

semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Esmail
Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have expected the same result in both cases. Initially I would have expected -3**2

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Brian J Mingus
On Sun, Nov 29, 2009 at 5:39 PM, Esmail ebo...@hotmail.com wrote: Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have

Re: Creating a local variable scope.

2009-11-29 Thread Steve Howell
On Nov 29, 4:26 pm, markolopa marko.lopa...@gmail.com wrote: Less than 3 hours have passed since my last post and got yet another bug that could be prevented if Python had the functionality that other languages have to destroy variables when a block ends. Here is the code: =

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Chris Rebert
On Sun, Nov 29, 2009 at 4:39 PM, Esmail ebo...@hotmail.com wrote: Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Esmail
Brian J Mingus wrote: I think you answered your own question. 3**2 comes first in the order of operations, followed by the negation. No, that's not the problem, I'm ok with the operator precedence of - vs ** My problem is why I don't get the same result if I use the literal -3 or a

Re: Variables with cross-module usage

2009-11-29 Thread Terry Reedy
Dennis Lee Bieber wrote: In these languages, the names always refer to the same location. Python confuses matters by having names that don't really refer to location, but are attached to the objects. In everyday life and natural languages, names refer to people, other objects, roles,

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Esmail
Chris Rebert wrote: _No_, because using the variable evaluates -3 as a unit separately by itself, before the exponentiation ever occurs; it's the same as the difference between (-3)**2 and -3**2. Python is not a concatenative programming language[*]; you can't directly textually replace a

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Colin W.
On 29-Nov-09 19:50 PM, Chris Rebert wrote: On Sun, Nov 29, 2009 at 4:39 PM, Esmailebo...@hotmail.com wrote: Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Martin v. Löwis
I think you answered your own question. 3**2 comes first in the order of operations, followed by the negation. No, that's not the problem, I'm ok with the operator precedence of - vs ** My problem is why I don't get the same result if I use the literal -3 or a variable that contains -3 (x

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread The Music Guy
It's just like in algebra. You evaluate exponents before the - which, after all, is just another way to write -1, or times-negative-one. However, a variable with a negative value is not the same as a value that is being multiplied by a negative. -3 ** 2 = (-1)(3)^(2) in algebraic terms.

Re: Feature request: String-inferred names

2009-11-29 Thread Terry Reedy
The Music Guy wrote: When I first started seeing @ show up in Python code, I said what the heck is that? For future reference, PySymbols.html at http://code.google.com/p/xploro/downloads/list answers all such symbol questions. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a local variable scope.

2009-11-29 Thread Alf P. Steinbach
* markolopa: On 18 Sep, 10:36, markol...@gmail.com markol...@gmail.com wrote: On Sep 11, 7:36 pm, Johan Grönqvist johan.gronqv...@gmail.com wrote: I find several places in my code where I would like tohavea variable scope that is smaller than the enclosing function/class/module definition.

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Ben Finney
Esmail ebo...@hotmail.com writes: Brian J Mingus wrote: I think you answered your own question. 3**2 comes first in the order of operations, followed by the negation. No, that's not the problem, I'm ok with the operator precedence of - vs ** My problem is why I don't get the same

Re: slightly OT: Python BootCamp

2009-11-29 Thread Terry Reedy
J wrote: Ok... so I've been re-teaching myself python, as it's been several years since I last really used it. And in the midst of this, my contracting company came up to me on Friday and asked if I'd be interested in filling a last minute vacancy in this: http://www.otg-nc.com/python-bootcamp

Re: [Edu-sig] teaching python using turtle module

2009-11-29 Thread kirby urner
On Sun, Nov 29, 2009 at 2:51 PM, Edward Cherlin echer...@gmail.com wrote: snip Drunkard's Walk. If our think tank (isepp.org) could have gotten permission, we'd have used that Monopoly guy (looks kinda like Planters peanut guy) randomly walking on like some chess board with a lamp post

Re: python and vc numbers

2009-11-29 Thread Gregory Ewing
Daniel Dalton wrote: what function/module should I use to figure out what tty my program was invoked from? Here's one way: % python Python 2.5 (r25:51908, Apr 8 2007, 22:22:18) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type help, copyright, credits or license for more

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Alf P. Steinbach
* Esmail: Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have expected the same result in both cases. Initially I would have

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Mel
Esmail wrote: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have expected the same result in both cases. Initially I would have expected -3**2

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Esmail
Thanks all!! I get it now :-) It helped to have a number of different explanations, thanks for taking the time to post. Much appreciated. Cheers, Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-11-29 Thread Lie Ryan
On 11/29/2009 12:22 PM, The Music Guy wrote: When I first started seeing @ show up in Python code, I said what the heck is that? It looks so weird and _ugly_.I would never try to mess with that. But I started seeing it more and more, so I asked #python what it was. They told me about decorators,

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Lie Ryan
On 11/30/2009 12:38 PM, Esmail wrote: Thanks all!! I get it now :-) It helped to have a number of different explanations, thanks for taking the time to post. Much appreciated. I generally do not expect operator precedence to be reliable at all except for: + - (binary ops, not the unary) *

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Ben Finney
Lie Ryan lie.1...@gmail.com writes: I generally do not expect operator precedence to be reliable at all Have another read of the thread. The OP's confusion was not over operator precedence, but over how names resolve to values in expressions. -- \ “Life does not cease to be funny when

Object Not Callable, float?

2009-11-29 Thread W. eWatson
Here's an traceback error msg I get. Exception in Tkinter callback Traceback (most recent call last): File C:\Python25\lib\lib-tk\Tkinter.py, line 1403, in __call__ return self.func(*args) File

Re: Object Not Callable, float?

2009-11-29 Thread Ben Finney
W. eWatson wolftra...@invalid.com writes: C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py, line 467, in ShowHistogram mean = sum(hist) TypeError: 'float' object is not callable It means you're calling an object of type ‘float’. The

Noobie python shell question

2009-11-29 Thread tuxsun
I've been working in the shell on and off all day, and need to see if a function I defined earlier is defined in the current shell I'm working in. Is there a shell command to get of list of functions I've defined? TIA! P.S. If it makes a difference, I'm using the shell from within IDLE, but

ANN: GMPY 1.11rc1 is available

2009-11-29 Thread casevh
Everyone, I'm pleased to annouce that a new version of GMPY is available. GMPY is a wrapper for the MPIR or GMP multiple-precision arithmetic library. GMPY 1.11rc1 is available for download from: http://code.google.com/p/gmpy/ In addition to support for Python 3.x, there are several new

Re: Exec Statement Question

2009-11-29 Thread Dave Angel
Victor Subervi wrote: Hi; I have the following line of code: exec('%s()' % table) where 'table' is a variable in a for loop that calls variables from another script. I've made it so that it only calls one variable. I know for a fact that it's calling that variable in the script because it

Re: Creating a local variable scope.

2009-11-29 Thread Dave Angel
markolopa wrote: snip === arg_columns =] for domain in self.domains: i =elf.get_column_index(column_names, domain.name) col =olumn_elements[i] if len(col) !=en(val_column): ValueError('column %s has not the same size as the value column %s' %

Re: Noobie python shell question

2009-11-29 Thread Tim Chase
tuxsun wrote: I've been working in the shell on and off all day, and need to see if a function I defined earlier is defined in the current shell I'm working in. Is there a shell command to get of list of functions I've defined? yesish...you can use dir() from the prompt to see the bound names

Re: Feature request: String-inferred names

2009-11-29 Thread Carl Banks
On Nov 26, 3:43 pm, The Music Guy music...@alphaios.net wrote: That aside, I still feel that a new syntax would be a better solution than a new class. And, anyway, what I'm proposing isn't *quite* the same as what Ben North proposed. Ben's idea was *strictly* to create shorthand syntax to the

Re: Feature request: String-inferred names

2009-11-29 Thread Carl Banks
On Nov 28, 3:38 am, The Music Guy fearsomedragon...@gmail.com wrote: On Nov 28, 3:07 am, Lie Ryan lie.1...@gmail.com wrote: If you use it a lot, it is likely 1) you have abused class syntax for what should have been a dict or 2) what you need is to override __getattr__/__getattribute__ and

Re: Feature request: String-inferred names

2009-11-29 Thread Brad Harms
On Sun, Nov 29, 2009 at 7:49 PM, Lie Ryan lie.1...@gmail.com wrote: On 11/29/2009 12:22 PM, The Music Guy wrote: When I first started seeing @ show up in Python code, I said what the heck is that? It looks so weird and _ugly_.I would never try to mess with that. But I started seeing it more

Re: Noobie python shell question

2009-11-29 Thread Dave Angel
tuxsun wrote: I've been working in the shell on and off all day, and need to see if a function I defined earlier is defined in the current shell I'm working in. Is there a shell command to get of list of functions I've defined? TIA! P.S. If it makes a difference, I'm using the shell from

Re: Noobie python shell question

2009-11-29 Thread Chris Rebert
On Sun, Nov 29, 2009 at 7:53 PM, Tim Chase python.l...@tim.thechases.com wrote: snip (as an aside, is there a way to get a local/global variable from a string like one can fetch a variable from a class/object with getattr()?  Something like getattr(magic_namespace_here, hello) used in the above

Re: Best strategy for overcoming excessive gethostbyname timeout.

2009-11-29 Thread MrJean1
Take a look at function timelimited in this recipe http://code.activestate.com/recipes/576780/ /Jean On Nov 29, 8:08 am, r0g aioe@technicalbloke.com wrote: r0g wrote: r0g wrote: Gabriel Genellina wrote: En Fri, 27 Nov 2009 22:35:36 -0300, r0g aioe@technicalbloke.com escribió:

Re: Object Not Callable, float?

2009-11-29 Thread W. eWatson
Ben Finney wrote: W. eWatson wolftra...@invalid.com writes: C:\Sandia_Meteors\Sentinel_Development\Development_Sentuser+Utilities\sentuser\sentuser_20090103+hist.py, line 467, in ShowHistogram mean = sum(hist) TypeError: 'float' object is not callable It means you're calling an object of

Re: Creating a local variable scope.

2009-11-29 Thread Terry Reedy
markolopa wrote: so domain should not exist in my namespace since I have no information associated to domain only to self.domains. Python should allow me to write safe code! Leaving iteration names bound after loop exit is a feature. If you do not like it, explicitly unbind it. --

Re: Object Not Callable, float?

2009-11-29 Thread John Bokma
W. eWatson wolftra...@invalid.com wrote: Yikes. Thanks very much. Python seems to act unlike other language in which words like float are reserved. I'll use asum. The problem is that there is a function sum and you creating a float sum: sum = 0.0 and mean = sum(hist) even if both could

Re: Noobie python shell question

2009-11-29 Thread Dave Angel
Tim Chase wrote: snip (as an aside, is there a way to get a local/global variable from a string like one can fetch a variable from a class/object with getattr()? Something like getattr(magic_namespace_here, hello) used in the above context? I know it can be done with eval(), but that's

Re: Feature request: String-inferred names

2009-11-29 Thread Brad Harms
On Sun, Nov 29, 2009 at 9:59 PM, Carl Banks pavlovevide...@gmail.comwrote: Another thing that can be determined through common sense is that if you have object that you are calling getattr and setattr on so much that you think you need special syntax, you should have been using a dict.

  1   2   >