Re: Question on Python Function

2010-05-24 Thread Kushal Kumaran
On Tue, May 25, 2010 at 3:38 AM, joy99 wrote: > > > Dear Vlastimir, > > As pointed out by Alister, I can print the values of function1 and > function2 with the help of another function3, but my target is to call > the "add" value of function1 and "mult" value of function2 in a third > function or

Re: Drilling down in a dict with "complex" objects

2010-05-24 Thread Chris Rebert
On Mon, May 24, 2010 at 9:34 PM, Six wrote: > I am trying to access an objects sub-object attributes. I can boil the > code I am working with down to this problem section: > (snip) > class Pt: >  x = None >  y = None >  def __init__(self, x, y): >    self.x, self.y = x, y >  pass > > class Pts: >

Re: Drilling down in a dict with "complex" objects

2010-05-24 Thread Terry Reedy
On 5/25/2010 12:34 AM, Six wrote: [snip] It's this last line that doesn't work. What am I doing wrong? When posting such questios, print the traceback if there is one or otherwise describe 'does not work' in much more detail. -- http://mail.python.org/mailman/listinfo/python-list

Re: Drilling down in a dict with "complex" objects

2010-05-24 Thread Benjamin Kaplan
On Mon, May 24, 2010 at 9:34 PM, Six wrote: > I am trying to access an objects sub-object attributes. I can boil the > code I am working with down to this problem section: > (snip) > class Pt: >  x = None >  y = None >  def __init__(self, x, y): >    self.x, self.y = x, y >  pass > > class Pts: >

Re: Drilling down in a dict with "complex" objects

2010-05-24 Thread Sean DiZazzo
On May 24, 9:34 pm, Six wrote: > I am trying to access an objects sub-object attributes. I can boil the > code I am working with down to this problem section: > (snip) > class Pt: >   x = None >   y = None >   def __init__(self, x, y): >     self.x, self.y = x, y >   pass > > class Pts: >   curr_p

Re: python command line manual

2010-05-24 Thread Vito 'ZeD' De Tullio
Peng Yu wrote: > I mainly check online python manual. But I feel that it would be nice > if there is command line manual available (just like perl command line > manual). Could you please let me know if such command line manual > available? pydoc? -- By ZeD -- http://mail.python.org/mailman/

Drilling down in a dict with "complex" objects

2010-05-24 Thread Six
I am trying to access an objects sub-object attributes. I can boil the code I am working with down to this problem section: (snip) class Pt: x = None y = None def __init__(self, x, y): self.x, self.y = x, y pass class Pts: curr_point = None next_point = None def __init__(self, n,

Re: help with the Python 3 version of the decorator module

2010-05-24 Thread Michele Simionato
On May 22, 10:49 am, Michele Simionato wrote: > I have finally decided to port the decorator module to Python 3. > Changing the module was zero effort (2to3 worked) but changing the > documentation was quite an effort, since I had to wait for docutils/ > pygements to support Python 3 and to change

Re: Generator expressions vs. comprehensions

2010-05-24 Thread Michele Simionato
On May 25, 12:47 am, Carl Banks wrote: > The situation here is known.  It can't be corrected, even in Python 3, > without modifying iterator protocol to tie StopIteration to a specific > iterator.  This is possible and might be worth it to avoid hard-to- > diagnose bugs but it would complicate ite

Re: Chatroom

2010-05-24 Thread Mark Lawrence
On 24/05/2010 19:50, narcissus wrote: Hello , I want to create a program that is one chatroom and everyone has this program can Enter into that chatroom. how can i do this? and i want gui for it too (GTK) Use your favourite editor and/or IDE to create your program, run it and when you run into

Re: Chatroom

2010-05-24 Thread Shashwat Anand
seems like an academic project which is worth grades On Tue, May 25, 2010 at 7:01 AM, alex23 wrote: > "Martin P. Hellwig" wrote: > > What have you tried so far? > > Alternatively, how much is it worth to you? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.

Re: python command line manual

2010-05-24 Thread Asun Friere
On May 25, 8:52 am, Peng Yu wrote: > I mainly check online python manual. But I feel that it would be nice > if there is command line manual available (just like perl command line > manual). Could you please let me know if such command line manual > available? > > -- > Regards, > Peng It's not re

Re: Chatroom

2010-05-24 Thread alex23
"Martin P. Hellwig" wrote: > What have you tried so far? Alternatively, how much is it worth to you? -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQL, Python, NumPy and formatted read

2010-05-24 Thread Ian Hoffman
On May 24, 2:11 am, Dennis Lee Bieber wrote: > On Sun, 23 May 2010 21:44:30 -0700 (PDT), Ian Hoffman > declaimed the following in gmane.comp.python.general: > > > The problem is the tuple is contained in a single value separated by > > newlines (only a[0] has a record), otherwise I could do as yo

Re: python command line manual

2010-05-24 Thread Steven D'Aprano
On Mon, 24 May 2010 17:52:13 -0500, Peng Yu wrote: > I mainly check online python manual. But I feel that it would be nice if > there is command line manual available (just like perl command line > manual). Could you please let me know if such command line manual > available? >From the shell, you

Re: Generator expressions vs. comprehensions

2010-05-24 Thread Antoine Pitrou
On Mon, 24 May 2010 15:47:32 -0700 (PDT) Carl Banks wrote: > > > > Is this distinction generally known? Yes, it is. > > The generator expression > > behavior is understandable since a generator would do the same thing, > > but I'm disappointed that the inconsistency exists and wasn't fixed in >

wxPython 2.8.11.0 release

2010-05-24 Thread Robin Dunn
Announcing -- The 2.8.11.0 release of wxPython is now available for download at http://wxpython.org/download.php. This release adds Python 2.7 builds, PySlices, new pubsub implementation, lots of updates to AGW, and lots of bugs fixed. A summary of changes is listed below and also at htt

Internationalizing an application via Babel

2010-05-24 Thread python
I'm evaluating Babel 0.9.5 [1] under Windows (Python 2.6) and have the following questions that I haven't been able to solve through reading the documentation or googling. 1. I would like to use an _ like abbreviation for ungettext. Is there a concencus on whether one should use n_ or N_ for this

Re: python command line manual

2010-05-24 Thread Chris Rebert
On Mon, May 24, 2010 at 3:52 PM, Peng Yu wrote: > I mainly check online python manual. But I feel that it would be nice > if there is command line manual available (just like perl command line > manual). Could you please let me know if such command line manual > available? 98% sure that there isn

python command line manual

2010-05-24 Thread Peng Yu
I mainly check online python manual. But I feel that it would be nice if there is command line manual available (just like perl command line manual). Could you please let me know if such command line manual available? -- Regards, Peng -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator expressions vs. comprehensions

2010-05-24 Thread Carl Banks
On May 24, 3:31 pm, Ian Kelly wrote: > Hi all, > > I just ran into an interesting but rather subtle little wart today. > The following expressions are not functionally equivalent, even in > Python 3: > > tuple(iterator.next() for i in xrange(n)) > > tuple([iterator.next() for i in xrange(n)]) > >

Re: Most reliable/pythonic way to tell if an instance comes from a class implemented in C/etc?

2010-05-24 Thread Carl Banks
[Following up to Terry Reedy's post since I don't see the original] On May 24, 11:30 am, Terry Reedy wrote: > On 5/24/2010 12:56 PM, Nathan Rice wrote: > > > I'm trying to do some fairly deep introspection and instrumentation of > > instances and classes at runtime, and in order for everything to

Generator expressions vs. comprehensions

2010-05-24 Thread Ian Kelly
Hi all, I just ran into an interesting but rather subtle little wart today. The following expressions are not functionally equivalent, even in Python 3: tuple(iterator.next() for i in xrange(n)) tuple([iterator.next() for i in xrange(n)]) In the first case, if iterator.next() raises a StopItera

Re: Question on Python Function

2010-05-24 Thread joy99
On May 25, 1:56 am, Vlastimil Brom wrote: > 2010/5/24 joy99 : > > > > > > > > > Dear Group, > > > I have a small question on function. > > > If I write two functions like the following: > > > IDLE 2.6.5 > def function1(n): > >        element1=5 > >        element2=6 > >        add=element1+el

Re: Question on Python Function

2010-05-24 Thread joy99
On May 25, 1:56 am, Vlastimil Brom wrote: > 2010/5/24 joy99 : > > > > > > > > > Dear Group, > > > I have a small question on function. > > > If I write two functions like the following: > > > IDLE 2.6.5 > def function1(n): > >        element1=5 > >        element2=6 > >        add=element1+el

Re: Question on Python Function

2010-05-24 Thread Alister
On Mon, 24 May 2010 22:56:34 +0200, Vlastimil Brom wrote: > 2010/5/24 joy99 : >> >> >> Dear Group, >> >> I have a small question on function. >> >> If I write two functions like the following: >> >> IDLE 2.6.5 > def function1(n): >>        element1=5 >>        element2=6 >>        add=element1

Re: Question on Python Function

2010-05-24 Thread Vlastimil Brom
2010/5/24 joy99 : > > > Dear Group, > > I have a small question on function. > > If I write two functions like the following: > > IDLE 2.6.5 def function1(n): >        element1=5 >        element2=6 >        add=element1+element2 >        print "PRINT THE ADDITION",add > > def function2(n

Re: Question on Python Function

2010-05-24 Thread Alister
On Mon, 24 May 2010 13:15:01 -0700, joy99 wrote: > Dear Group, > > I have a small question on function. > > If I write two functions like the following: > > IDLE 2.6.5 def function1(n): > element1=5 > element2=6 > add=element1+element2 > print "PRINT THE ADDITION",a

Re: function that counts...

2010-05-24 Thread superpollo
Jean-Michel Pichavant ha scritto: Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): """How many

Question on Python Function

2010-05-24 Thread joy99
Dear Group, I have a small question on function. If I write two functions like the following: IDLE 2.6.5 >>> def function1(n): element1=5 element2=6 add=element1+element2 print "PRINT THE ADDITION",add >>> def function2(n): element3=7 element4=

Re: Most reliable/pythonic way to tell if an instance comes from a class implemented in C/etc?

2010-05-24 Thread Duncan Booth
Terry Reedy wrote: > Builtin classes, named or not, do not have dotted names > > >>> 1 .__class__ > > >>> class C: pass > > I believe all others do, including C-coded extension classes. > > >>> C().__class__ > > Not quite all. Classes created by calling the type constructor directly don't h

D-CM IDE

2010-05-24 Thread Kruptein
I'm developing an "IDE" in python (wxPython toolkit). it's an application that combines a file-manager,text-editor,sql-manager,ftp- manager and more in one simple to use GUI. I'm releasing a new version soon and I hoped that there were some folks in here that would like to test if it worked well.

Re: Chatroom

2010-05-24 Thread Martin P. Hellwig
On 05/24/10 19:50, narcissus wrote: Hello , I want to create a program that is one chatroom and everyone has this program can Enter into that chatroom. how can i do this? and i want gui for it too (GTK) What have you tried so far? -- mph -- http://mail.python.org/mailman/listinfo/python-list

Chatroom

2010-05-24 Thread narcissus
Hello , I want to create a program that is one chatroom and everyone has this program can Enter into that chatroom. how can i do this? and i want gui for it too (GTK) -- http://mail.python.org/mailman/listinfo/python-list

Re: Most reliable/pythonic way to tell if an instance comes from a class implemented in C/etc?

2010-05-24 Thread Terry Reedy
On 5/24/2010 12:56 PM, Nathan Rice wrote: I'm trying to do some fairly deep introspection and instrumentation of instances and classes at runtime, and in order for everything to be properly behaved I need to have radically different behavior in the event that the thing passed to me is a wrapped c

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Terry Reedy
On 5/24/2010 10:42 AM, MRAB wrote: Mark Dickinson wrote: Digging a bit deeper, it looks like these methods are using the Simple_{Upper,Lower,Title}case_Mapping functions described at http://www.unicode.org/Public/5.1.0/ucd/UCD.html fields 12, 13 and 14 of the unicode data; you can see this in

A Quick MySQL Question

2010-05-24 Thread Victor Subervi
Hi; I have the following: #sql = 'alter table %s alter column %s set default "%%s";' % (store, col) #cursor.execute(sql, colValue) cursor.execute('alter table %s alter column %s set default "%s";' % (store, col, colValue)) database.commit() Now I don't like that th

Most reliable/pythonic way to tell if an instance comes from a class implemented in C/etc?

2010-05-24 Thread Nathan Rice
I'm trying to do some fairly deep introspection and instrumentation of instances and classes at runtime, and in order for everything to be properly behaved I need to have radically different behavior in the event that the thing passed to me is a wrapped class/instance. Is there a really good way,

Re: launching vi/vim from console

2010-05-24 Thread Shashwat Anand
or in a reverse way you can open vim and use ':shell' followed by python. I prefer it that way generally On Mon, May 24, 2010 at 6:01 PM, adm wrote: > On May 24, 4:59 pm, Jean-Michel Pichavant > wrote: > > adm wrote: > > > I am newbie to python. > > > Is there a way to launch vi/vim or any othe

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
Dirk Nachbar wrote: Sorry guys, I had named my file email.py and hence the error. On 24 May 2010 15:22, Jean-Michel Pichavant > wrote: dirknbr wrote: I have now easy_installled email and I still get errors. It doesn't error on 'import ema

Re: function that counts...

2010-05-24 Thread Matteo Landi
What about avoiding the string conversion and use mod/div operations in order to create a list of digits for a number? Now that you have the sequences it's easy to count which sums up to m. On Mon, May 24, 2010 at 4:14 PM, Raymond Hettinger wrote: > On May 19, 12:58 pm, superpollo wrote: >> ...

Re: function that counts...

2010-05-24 Thread Jean-Michel Pichavant
Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): """How many positive integers less than n hav

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread MRAB
Mark Dickinson wrote: On May 24, 1:13 pm, Steven D'Aprano wrote: Do unicode.lower() or unicode.upper() ever change the length of the string? The Unicode standard allows for case conversions that change length, e.g. sharp-S in German should convert to SS: http://unicode.org/faq/casemap_charpro

Re: Email in 2.6.4

2010-05-24 Thread Dirk Nachbar
Sorry guys, I had named my file email.py and hence the error. On 24 May 2010 15:22, Jean-Michel Pichavant wrote: > dirknbr wrote: > >> I have now easy_installled email and I still get errors. >> >> >> It doesn't error on 'import email' but does on call to MimeText. >> >> import email >> msg =

Re: Email in 2.6.4

2010-05-24 Thread Mark Lawrence
On 24/05/2010 14:59, dirknbr wrote: I have now easy_installled email and I still get errors. I've done this as well, but don't see why I have to. Is this a documentation bug, an installation bug or what? It doesn't error on 'import email' but does on call to MimeText. import email msg = MIME

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
dirknbr wrote: I have now easy_installled email and I still get errors. It doesn't error on 'import email' but does on call to MimeText. import email msg = MIMEText('test') NameError: name 'MIMEText' is not defined What should I do? Using easy_install will not prevent the standard lib to b

Re: Email in 2.6.4

2010-05-24 Thread Simon Brunning
On 24 May 2010 14:59:24 UTC+1, dirknbr wrote: > It doesn't error on 'import email' but does on call to MimeText. > > import email > msg = MIMEText('test') > > NameError: name 'MIMEText' is not defined Here you want: msg = email.MIMEText('test') -- Cheers, Simon B. -- http://mail.python.org/ma

Re: [BangPypers] extracting unicode text from pdfs

2010-05-24 Thread Dhananjay Nene
You may want to try out pdfminer. Its very similar to xpdf in structure and should give you the parsed data into unicode directly. On Mon, May 24, 2010 at 7:13 PM, Eknath Venkataramani wrote: > I have around 45 pdfs to convert into raw text containing text in _HINDI_ . > When I use the xpdf pack

Re: function that counts...

2010-05-24 Thread Raymond Hettinger
On May 19, 12:58 pm, superpollo wrote: > ... how many positive integers less than n have digits that sum up to m: > > In [197]: def prttn(m, n): >      tot = 0 >      for i in range(n): >          s = str(i) >          sum = 0 >          for j in range(len(s)): >              sum += int(s[j]) >  

Re: Email in 2.6.4

2010-05-24 Thread dirknbr
I have now easy_installled email and I still get errors. It doesn't error on 'import email' but does on call to MimeText. import email msg = MIMEText('test') NameError: name 'MIMEText' is not defined What should I do? -- http://mail.python.org/mailman/listinfo/python-list

extracting unicode text from pdfs

2010-05-24 Thread Eknath Venkataramani
I have around 45 pdfs to convert into raw text containing text in _HINDI_ . When I use the xpdf package, the generated text is very weird, so I'd like to write a program which would convert the pdf text into Unicode text as it is. The fonts used in the pdfs: name

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
dirknbr wrote: I am trying to run from email.mime.text import MIMEText but I get an ImportError: No module named mime.text Since email was pre-installed how do I fix this? Dirk Did you make sure you didn't hide the standard email module by one of your own. Check print email.__file__ /us

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Mark Dickinson
On May 24, 1:13 pm, Steven D'Aprano wrote: > Do unicode.lower() or unicode.upper() ever change the length of the > string? > > The Unicode standard allows for case conversions that change length, e.g. > sharp-S in German should convert to SS: > > http://unicode.org/faq/casemap_charprop.html#6 > >

Re: launching vi/vim from console

2010-05-24 Thread adm
On May 24, 4:59 pm, Jean-Michel Pichavant wrote: > adm wrote: > > I am newbie to python. > > Is there a way to launch vi/vim or any other editor from python > > console? I find editing in console very limiting. I can either have a > > console which launches vi and remembers it's content and then e

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Mark Dickinson
On May 24, 1:13 pm, Steven D'Aprano wrote: > Do unicode.lower() or unicode.upper() ever change the length of the > string? >From looking at the source, in particular the fixupper and fixlower functions in Objects/unicode.c [1], it looks like not: they do a simple character-by-character replaceme

Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Steven D'Aprano
Do unicode.lower() or unicode.upper() ever change the length of the string? The Unicode standard allows for case conversions that change length, e.g. sharp-S in German should convert to SS: http://unicode.org/faq/casemap_charprop.html#6 but I see that Python doesn't do that: >>> s = "Paßstraß

Re: launching vi/vim from console

2010-05-24 Thread Jean-Michel Pichavant
adm wrote: I am newbie to python. Is there a way to launch vi/vim or any other editor from python console? I find editing in console very limiting. I can either have a console which launches vi and remembers it's content and then executes or invoke python interpreter from vim. Since I could not

Email in 2.6.4

2010-05-24 Thread dirknbr
I am trying to run from email.mime.text import MIMEText but I get an ImportError: No module named mime.text Since email was pre-installed how do I fix this? Dirk -- http://mail.python.org/mailman/listinfo/python-list

launching vi/vim from console

2010-05-24 Thread adm
I am newbie to python. Is there a way to launch vi/vim or any other editor from python console? I find editing in console very limiting. I can either have a console which launches vi and remembers it's content and then executes or invoke python interpreter from vim. Since I could not find anything

Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-24 Thread Frank GOENNINGER
Philip Semanchuk writes: > On May 23, 2010, at 9:46 AM, Frank GOENNINGER wrote: >> >> I double checked and yes, getLogger is there. Why is the interpreter >> asking for an "attribute" here ? Any hints on what I am doing wrong ? > > > Short answer: Change the name of src/pib/logging.py to somethin

Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-24 Thread Frank GOENNINGER
Simon Brunning writes: > On 23 May 2010 14:46, Frank GOENNINGER wrote: >> Traceback (most recent call last): >>  File "/.../src/pib/logging.py", line 37, in >>    main() > > Here's a clue - looks like your own module is called logging. That's > what's getting imported by your import. Try naming

Re: Help with PyQt4 tabwidget setup

2010-05-24 Thread Neil Wallace
On Fri, 21 May 2010 08:03:43 +0200, dpalmboom wrote: > I am creating an application and I'm busy designing the main layout on > the main window. What I would like to do is the following: > > Create a QTabWidget with a QVBoxLayout already inside it and also a > scrollbar inside it. When a user tri