Re: smtplib with Google

2010-09-13 Thread member thudfoo
On Mon, Sep 13, 2010 at 9:20 AM, narke narkewo...@gmail.com wrote:

 Hi,

 Can anyone please show me a workable example that can let me use
 google's smtp server to send out a message?  Thanks.


Go here:

  http://code.activestate.com/recipes/langs/python/

and search for this

 gmail
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-14 Thread member thudfoo
On 8/14/10, Baba raoul...@gmail.com wrote:
 On Aug 13, 8:25 pm, Ian Kelly ian.g.ke...@gmail.com wrote:

 It's not.  You're not just trying to find the sixth value that can be
 bought in exact quantity, but a sequence of six values that can all be
 bought in exact quantity.  The integers [6, 9, 12, 15, 18, 20] are not
 sequential.

 Hi Ian,

 Thanks for stating the obvious. I obviously hadn't understood a
 fundamental part of the theorem which states that 6 SEQUENTIAL passes
 must be found! That's a good lesson learned and will help me in future
 exercises to make sure i understand the theory first. Thanks again!

 Ok so with your and News123's help (no offence to all others but i
 need to keep it simple at this stage)i was able to find the solution:
 43

 my code is probably not elegant but a huge step forward from where i
 started:

 def can_buy(n_nuggets):
for a in range (0,n_nuggets):
for b in range (0,n_nuggets):
for c in range (0,n_nuggets):
#print trying for %d: %d %d %d % (n_nuggets,a,b,c)
if 6*a+9*b+20*c==n_nuggets:
return [a,b,c]
return []

 for n_nuggets in range(50):
 result1 = can_buy(n_nuggets)
 result2 = can_buy(n_nuggets+1)
 result3 = can_buy(n_nuggets+2)
 result4 = can_buy(n_nuggets+3)
 result5 = can_buy(n_nuggets+4)
 result6 = can_buy(n_nuggets+5)
 if result1!=[] and result2!=[] and result3!=[] and result4!=[] and
 result5!=[] and result6!=[]:
  if (n_nuggets+5)-n_nuggets==5:
 print n_nuggets-1
 break

 i suppose this can be tweaked to make it shorter? For instance i
 wonder if i can do the same with less variable to be defined?

 tnx
 Baba


One tweak:

def can_buy(n_nuggets):
  for a in range (0,n_nuggets):
  for b in range (0,n_nuggets):
  for c in range (0,n_nuggets):
  #print trying for %d: %d %d %d % (n_nuggets,a,b,c)
  if 6*a+9*b+20*c==n_nuggets:
  return [a,b,c]
  return []

for n_nuggets in range(50):
if (can_buy(n_nuggets)
and can_buy(n_nuggets+1)
and can_buy(n_nuggets+2)
and can_buy(n_nuggets+3)
and can_buy(n_nuggets+4)
and can_buy(n_nuggets+5)):
   print n_nuggets - 1
   break
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread member thudfoo
On Tue, Jul 6, 2010 at 6:40 AM, Michael Torrie torr...@gmail.com wrote:
 On 07/06/2010 04:12 AM, sturlamolden wrote:
 On 28 Jun, 19:39, Michael Torrie torr...@gmail.com wrote:

 In python I could simply take the output of ps ax and use python's
 own, superior, cutting routines (using my module):

 (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
 for x in stdout.split('\n'):
     print x.strip().split()[0]

 Or you just pass the stdout of one command as stdin to another. That
 is equivalent of piping with bash.

 Consider this contrived example:

 tail -f /var/log/messages | grep openvpn

 While it's possible to set up pipes and spawn programs in parallel to
 operate on the pipes, in practice it's simpler to tell subprocess.Popen
 to use a shell and then just rely on Bash's very nice syntax for setting
 up the pipeline.  Then just read the final output in python.  If you set
 the stdout descriptor to non-blocking, you could read output as it came.
 --
 http://mail.python.org/mailman/listinfo/python-list


Is this a discussion about the pipes module in the std library?
-- 
http://mail.python.org/mailman/listinfo/python-list


using the netflix api

2010-07-05 Thread member thudfoo
Has anyone had success using the netflix api with Netflix.py?
Especially getting access?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bash-style auto completion in command line program. use rlcomplete?

2010-05-22 Thread member thudfoo
On Sat, May 22, 2010 at 11:01 AM, ntwrkd ntw...@gmail.com wrote:
 I am trying to create a bash-style auto completion in a simple
 command-line and script-based program i created using cmd.
 I saw http://docs.python.org/library/rlcompleter.html, which I'm
 thinking is the way to go for my program to intercept the tab key.
 Would anyone have thoughts on this?

 I wish cmd or cmd2 had this functionality built-in.


It is built in. Check the cmd documentation for complete_* method of Cmd class.

Following is an example of it use for a command called open:

def complete_open(self, text, line, begidx, endidx):
asmfiles = glob('%s/*.asm' % ASMDIR)
matches = []
for path in asmfiles:
fname = os.path.basename(path)
if fname.startswith(text):
matches.append(fname)
return matches
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the matter with docs.python.org?

2010-05-19 Thread member thudfoo
On Wed, May 19, 2010 at 9:23 AM, Christian Mertes
cmer...@techfak.uni-bielefeld.de wrote:
 by kjon 2010-03-24T16:40:21+00:00.
 In Philip Semanchuk writes:
 On Mar 24, 2010, at 12:05 PM, kj wrote:
  In the last couple of weeks, docs.python.org has been down repeatedly
  (like right now). Has anyone else noticed this?
 http://downforeveryoneorjustme.com/docs.python.org
 Very handy. Thanks!
 ~K

 Hey kjon,

 I just found your mail in the archives because I've been experiencing the
 same weird problems and I couldn't believe they wouldn't fix their server
 for such a long time. I'd like to know what downforeveryoneorjustme.com does
 because it's so lightning fast. Pinging the server? Works for me. Looking for
 port 80? It's open. Connecting to it and getting a web page? That's where 
 things
 start to get interesting:

 $ telnet docs.python.org 80
 Trying 2001:888:2000:d::a2...
 Trying 82.94.164.162...
 Connected to docs.python.org.
 Escape character is '^]'.
 GET / HTTP/1.0



 Connection closed by foreign host.

 ... after a really long time. The server wouldn't serve me. Opera reports a
 network error right away though, not waiting for a timeout. And the best part:
 Chrome and Firefox just get me the website. Wireshark reveals that both latter
 browsers get a 304 Not Modified response and then do a lot of weird stuff 
 involving
 DNS as well as HTTP to finally deliver a web page. Opera does no such thing 
 but only
 sends a request to 2001:888:2000:d::a2. Yeah, right, that's an IPv6 address.
 I really don't understand the details of what's going on here but chances are
 that you also use Opera, kjon and those who replied to you didn't?

 I reported docs.python.org as a broken page to the Opera devs but I'm also 
 Ccing this
 mail to the server admin because this seems to be a more complex problem than 
 just
 a broken (if at all) web browser.

 Best regards,

        Christian


Worked for me:

~/isos2burn telnet docs.python.org 80
Trying 82.94.164.162...
Connected to docs.python.org.
Escape character is '^]'.
GET/HTTP/1.0
!DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN
htmlhead
title302 Found/title
/headbody
h1Found/h1
pThe document has moved a href=http://www.python.org;here/a./p
hr
addressApache/2.2.9 (Debian) DAV/2 SVN/1.5.1 mod_ssl/2.2.9
OpenSSL/0.9.8g mod_wsgi/2.5 Python/2.5.2 Server at dinsdale.python.org
Port 80/address
/body/html
Connection closed by foreign host.
~/isos2burn date
Wed May 19 09:49:11 PDT 2010
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to preserve hex value

2010-05-19 Thread member thudfoo
On Wed, May 19, 2010 at 11:38 AM, Back9 backgoo...@gmail.com wrote:
 Hi,

 When converting a hex value, I'd like to preserve the decimal
 position.
 For example, 0x0A is converted to 0A not just A in string.

 How do I do this?

 TIA
 --
 http://mail.python.org/mailman/listinfo/python-list

|109 '%02X' % 10
109 '0A'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing an assembler in Python

2010-03-03 Thread member thudfoo
On Tue, Mar 2, 2010 at 10:52 PM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 In article xns9d28186af890cfdnbgui7uhu5h8hrn...@127.0.0.1,
 Giorgos Tzampanakis  g...@hw.ac.uk wrote:

 I'm implementing a CPU that will run on an FPGA. I want to have a
 (dead) simple assembler that will generate the machine code for
 me. I want to use Python for that. Are there any libraries that
 can help me with the parsing of the assembly code?

 I wrote a PIC assembler in Python once. I didn't bother
 with any parsing libraries. I used a regular expression
 to split the input into tokens, then wrote ad-hoc
 parsing code in Python.

 --
 Greg
 --
 http://mail.python.org/mailman/listinfo/python-list


I used Plex.

The lexer is here: http://pastebin.com/9Rm4rDfu

The target for the assembler is a toy single-byte processor.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Sending an email alert

2009-08-28 Thread member thudfoo
On Fri, Aug 28, 2009 at 12:00 PM, Marc m...@marcd.org wrote:
[...]
     s = smtplib.SMTP('smtp.marcd.org')

 AttributeError: 'module' object has no attribute 'SMTP'



 The code I am trying to use is:



 import smtplib

[...]

Make sure you do not have a file called smtplib.py on the your python path:

put this statement after import smtplib:

print smtplib.__file__

in order to find out what smtplib is being imported.

HTH
 ___
 Tutor maillist  -  tu...@python.org
 http://mail.python.org/mailman/listinfo/tutor

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is feedparser deprecated?

2009-08-08 Thread member thudfoo
On Fri, Aug 7, 2009 at 6:10 PM, Gabriel Genellina gagsl-...@yahoo.com.arwrote:

 En Fri, 07 Aug 2009 16:07:48 -0300, John Nagle na...@animats.com
 escribió:

Feedparser requires SGMLlib, which has been removed from Python 3.0.
 Feedparser hasn't been updated since 2007. Does this mean Feedparser
 is dead?


 Since we have generic and easy of use XML parsers like ElementTree and
 lxml,  specialized rss parsers like feedparser are not so much required.
 I've used ElementTree when I had to parse an rss feed in the past (not so
 many times).

 --
 Gabriel Genellina


 --
 http://mail.python.org/mailman/listinfo/python-list


feedparser is much more than than an just  another xml
 parser.

Read its documetion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-10 Thread member thudfoo
On Fri, Jul 10, 2009 at 5:37 AM, Tim Chasepython.l...@tim.thechases.com wrote:
 m.reddy prasad reddy wrote:

 can any one tell me how to write assembly language programs in python...if
 no is there any other way to write the programs in python

 Bah, writing assembly language is easy in Python:

  print(MOV EAX, [EBX])
  print(XOR EBX, EBX)

 Just adjust the strings for your favorite processor architecture and Python
 will produce the assembly code you want.

 Now compiling assembly to *machine* code...or calling between Python and
 assembly...that's another matter.  But writing assembly language programs in
 Python?  Easy. ;-)


PyASM is a full-featured dynamic assembler written entirely in
Python. By dynamic, I mean that it can be used to generate and execute
machine code in python at runtime without requiring the generation of
object files and linkage. It essentially allow 'inline' assembly in
python modules on x86 platforms.

PyASM can also generate object files (for windows) like a traditional
standalone assembler, although you're probably better off using one of
the many freely available assemblers if this is you primary goal.

http://members.verizon.net/~olsongt/usersGuide.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source RSS Reader in Python?

2009-07-02 Thread member thudfoo
On Wed, Jul 1, 2009 at 4:18 PM, Alexalex.lavoro.pro...@gmail.com wrote:
 I am looking for an open source RSS reader (desktop, not online)
 written in Python but in vain. I am not looking for a package but a
 fully functional software.

 Google: python open source (rss OR feeds) reader

 Any clue ?
 --
 http://mail.python.org/mailman/listinfo/python-list


rawdog is an RSS Aggregator Without Delusions Of Grandeur. It is a
river of news-style aggregator: it uses feedparser to download feeds
in RSS, Atom and a variety of other formats, and (by default) produces
static HTML pages containing the newest articles in date order. For
example, rawdog's default configuration produces output that looks
like this:

http://offog.org/code/rawdog.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Check module without import it

2009-06-22 Thread member thudfoo
On Mon, Jun 22, 2009 at 3:06 AM, Klessjonas@googlemail.com wrote:
 Is there any way to check that it's installed a module without import
 it directly?

 I'm using the nex code but it's possible that it not been necessary to
 import a module

 -
 try:
   import module
 except ImportError:
   pass
 else:
   print 'make anything'
 -

Have a look at  find_module in the imp module of the standard library.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good books in computer science?

2009-06-15 Thread member thudfoo
On 6/15/09, Terry Reedy tjre...@udel.edu wrote:
 Phil Runciman wrote:

 
  Gain access to one of the IEEE or ACM web sites and their resources.
  I used to sneak into my local university library before the 'Net to
  read this stuff.
 
  Beyond that I check up on the reading lists for CS students from time
  to time. This often throws up real gems and prevents me from being
  blind-sided.
 

  For those who are not rich, MIT has put a lot of courseware on the web,
 including in particular, CS, for free.  And there is lots more put up by
 professors and departments elsewhere.  There are free language manuals and
 interpreters/compilers for those who want to stretch their brain that way.



The MIT Online Course Ware starts here:

 http://ocw.mit.edu/OcwWeb/web/help/start/index.htm

I downloaded the Mathematics for Computer Science course: ~9MB. Looks
to be excellent!

Do you have links to share for the other materials?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating all combinations

2009-05-31 Thread member thudfoo
On 5/31/09, Scott David Daniels scott.dani...@acm.org wrote:
 Johannes Bauer wrote:

  Hello group,
 
  I'm trying to write a function in Python which does the following: For a
  number of arguments which are all lists, return a list (or generator)
  which yields all tuples of combination. E.g:
 

  Look here:

 http://docs.python.org/library/itertools.html#itertools.product

  (new in 2.6, but code works in lower versions).


How would one go about installing the python 2.6 itertools code in python 2.5?

  --Scott David Daniels
  scott.dani...@acm.org



  --
  http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with problem creating class

2009-04-18 Thread member thudfoo
On 4/18/09, auzarski2...@gmail.com auzarski2...@gmail.com wrote:
 Hi I have been working on a homework assignment that I am having a lot
  of trouble with.  I am so frustrated because every time I think I am
  getting close to figuring it out there is another problem.   If you
  could look at this and tell me what I am doing wrong I would very much
  appreciate it

  import string

  from datetime import date



  class Leaderapplicant:



 def __init__(self, line):

 #convert the lines of data into fields and removes
  \n

 line = line.rstrip(\n)

 appname, leadername, start, end = line.split(\t)

[...]


  I am using tab separated data in another file that looks like this...


  appname1   leadername12005, 02, 022006, 02, 02
  appname2   leadername22006, 03, 212007, 06, 28

  etc...

  The error message looks like this

   back (most recent call last):
   File /home/amy/Documents/LIS452/assignment 3/testworks.py, line
  97, in module
 main()
   File /home/amy/Documents/LIS452/assignment 3/testworks.py, line
  80, in main
 a = Leaderapplicant(line) #from data file
   File /home/amy/Documents/LIS452/assignment 3/testworks.py, line 9,
  in __init__
 appname, leadername, start, end = line.split(\t)
  ValueError: need more than 3 values to unpack

  Any help would be greatly appreciated.  I have spent so much time on
  this that I am behind not only in this class but in other classes as
  well.


Immediately before line 9 put the following line:

print line.split(\t)

Now run it again and see how many values are in  the list that is
printed. Your code expects that there will be exactly three.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with problem creating class

2009-04-18 Thread member thudfoo
Correction:

On 4/18/09, member thudfoo thud...@opensuse.us wrote:
 On 4/18/09, auzarski2...@gmail.com auzarski2...@gmail.com wrote:
   Hi I have been working on a homework assignment that I am having a lot
of trouble with.  I am so frustrated because every time I think I am
getting close to figuring it out there is another problem.   If you
could look at this and tell me what I am doing wrong I would very much
appreciate it
  
import string
  
from datetime import date
  
  
  
class Leaderapplicant:
  
  
  
   def __init__(self, line):
  
   #convert the lines of data into fields and removes
\n
  
   line = line.rstrip(\n)
  
   appname, leadername, start, end = line.split(\t)
  

 [...]


  
I am using tab separated data in another file that looks like this...
  
  
appname1   leadername12005, 02, 022006, 02, 02
appname2   leadername22006, 03, 212007, 06, 28
  
etc...
  
The error message looks like this
  
 back (most recent call last):
 File /home/amy/Documents/LIS452/assignment 3/testworks.py, line
97, in module
   main()
 File /home/amy/Documents/LIS452/assignment 3/testworks.py, line
80, in main
   a = Leaderapplicant(line) #from data file
 File /home/amy/Documents/LIS452/assignment 3/testworks.py, line 9,
in __init__
   appname, leadername, start, end = line.split(\t)
ValueError: need more than 3 values to unpack
  
Any help would be greatly appreciated.  I have spent so much time on
this that I am behind not only in this class but in other classes as
well.
  


 Immediately before line 9 put the following line:

 print line.split(\t)

  Now run it again and see how many values are in  the list that is
  printed. Your code expects that there will be exactly four.

--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 2.0

2009-04-14 Thread member thudfoo
On Tue, Apr 14, 2009 at 10:02 AM, Terry Reedy tjre...@udel.edu wrote:
 greg wrote:
[...]

fwiw, the following python script could be used, when run from the
Tests directory, to selectively run the numbered tests:

- runtests.py
import glob
import os
import subprocess
from GUI import Window, Menu, Label, application, stop_alert

class TestWindow(Window):

def setup_menus(self, m):
m.new_cmd.enabled = 0
m.open_cmd.enabled = 0
m.runtest.enabled = 1
for ndx in range(len(runmenuitems)):
if ndx in ranmenuitems:
m.runtest[ndx].checked = True

def runtest(self, i):
try:
filename = '%s.py' % runmenuitems[i]
retcode = subprocess.call(python %s % (filename), shell=True)
if retcode  0:
stop_alert(Child was terminated by signal + -retcode)
except OSError, e:
stop_alert(Execution of %s failed: %s % (filename, str(e)))
else:
ranmenuitems.add(i)

def getrunmenuitems():
filenames = glob.glob('./[0-9][0-9]-*.py')
menuitems = []
for filename in filenames:
menuitems.append(os.path.basename(filename)[:-3])
return sorted(menuitems)

runmenuitems = getrunmenuitems()
ranmenuitems = set()

win = TestWindow(title=Run Tests, size=(240, 60))
win.menus = [Menu('Run', [(runmenuitems, 'runtest')])]
win.add(Label(Select a test from the Run menu, position = (20, 20),
width = 200))
win.show()
application().run()
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 2.0

2009-04-11 Thread member thudfoo
Line 25 of setup.py should be:

packages.append(GUI.Gtk)
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: SuPy - Script Sketchup with Python

2009-02-06 Thread member thudfoo
On Fri, Feb 6, 2009 at 8:27 AM, Gary Herron gher...@islandtraining.com wrote:
 greg wrote:
 SuPy 1.0
 

 SuPy is a plugin for the Sketchup 3D modelling application
 that lets you script it in Python.

   http://www.cosc.canterbury.ac.nz/SuPy/


 That URL fails with a 404 - not found.  (At least for me at this moment
 in time.)



 This is a first version and is highly experimental. Let me
 know if it works for you and whether you have any problems.


 --
 http://mail.python.org/mailman/listinfo/python-list


This URL works:

http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/
--
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes with Compaq Visual Fortran 6.6B *.dll (Windows XP), passing of integer and real values

2009-01-29 Thread member thudfoo
On Thu, Jan 29, 2009 at 1:08 PM, alex ale...@bluewin.ch wrote:
 Duncan
 Thank you for your explanation of the relationship between calling
 convention and stack management.
 I will try to understand better this topic in the CVF and ctypes
 documentation (not so easy).

 Regards Alex

 --
 http://mail.python.org/mailman/listinfo/python-list


fwiw, ctypes has a mailing list:

https://lists.sourceforge.net/lists/listinfo/ctypes-users
--
http://mail.python.org/mailman/listinfo/python-list


Is there a best linux distro for a python hobbyist?

2009-01-05 Thread member thudfoo
One with all the major python GUIs: pyQT, pyGtk, pyKde, wxPython, 
And so on.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why not Ruby?

2008-12-31 Thread member thudfoo
2008/12/31 Giampaolo Rodola' gne...@gmail.com:
 On 31 Dic, 18:55, Xah Lee xah...@gmail.com wrote:
 Just spent 3 hours looking into Ruby today. Here's my short impression
[...]

 --- Giampaolo
 http://code.google.com/p/pyftpdlib


Hey, Giampaolo:

I had gone to the trouble to filter out the posts from xah lee, but
you have quoted his entire message. If you would like to scold xah
lee, you can do so directly without reposting to this fine newsgroup.

Thank You Very Much.

 --
 http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list


Re: Equivalent of 'wget' for python?

2008-12-11 Thread member thudfoo
On Mon, Dec 8, 2008 at 8:22 AM, Robert Dailey rcdai...@gmail.com wrote:
 Hi,

 I'm looking for a portable way to download ZIP files on the internet
 through Python. I don't want to do os.system() to invoke 'wget', since
 this isn't portable on Windows. I'm hoping the core python library has
 a library for this. Note that I'll be using Python 3.0.

 Thanks.
 --
 http://mail.python.org/mailman/listinfo/python-list


This module might be of interest:

http://linux.duke.edu/projects/urlgrabber/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Where can I get Lucid Toolkit?

2008-11-13 Thread member thudfoo
On 11/11/08, est [EMAIL PROTECTED] wrote:
 Hi guys,

  I tried to grab source code for  Lucid Toolkit 
 http://www.clarographics.org/svn_details
  which was mentioned http://wiki.python.org/moin/GuiProgramming

  So is this project abandoned? Is there any backup that I can get the
  code?

  Any other recommands for simple GUI development, with out large
  library runtime(qt, gtk, wx) ?


easygui?

 --
  http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes shared object FILE*

2008-11-13 Thread member thudfoo
On 11/8/08, Dog Walker [EMAIL PROTECTED] wrote:
 I need to call a function in a shared object with this signature:
  init_dialog(FILE *input, FILE *output)
  The FILE*'s are to stdin and stdout.

  The call from python is libdialog.init_dialog( x, y)
  I need to define x and y so that they will have the structure of
  sys.stdin and sys.stdout; the called function (init_dialog) is using a
  (std?) function fileno to extract the fileno from the FILE* describing
  stdin and stdout.
  How can I do this?


I should have said stderr rather than stdout.

And the answer is:

from ctypes import *
from ctypes.util import find_library
libc = CDLL(find_library(c))
libdialog = CDLL(find_library(dialog))
class FILE(Structure): pass

libdialog.init_dialog(POINTER(FILE).in_dll(libc, stdin),
POINTER(FILE).in_dll(libc, stderr))

  --
  I have seen the future and I'm not in it!

 --
  http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list


Re: very large dictionary

2008-08-03 Thread member thudfoo
On 3 Aug 2008 20:40:02 GMT, Jorgen Grahn [EMAIL PROTECTED] wrote:
 On 3 Aug 2008 20:36:33 GMT, Jorgen Grahn [EMAIL PROTECTED] wrote:
   On Fri, 1 Aug 2008 01:05:07 -0700 (PDT), Simon Strobl [EMAIL PROTECTED] 
 wrote:

 ...

  If there is no other way to do it, I will have to learn how to use
   databases in Python.
  
   If you use Berkeley DB (import bsddb), you don't have to learn much.
   These databases look very much like dictionaries string:string, only
   they are disk-backed.


 ... all of which Sean pointed out elsewhere in the thread.

  Oh well. I guess pointing it out twice doesn't hurt.  bsddb has been
  very pleasant to work with for me. I normally avoid database
  programming like the plague.



13.4 shelve -- Python object persistence

 A ``shelf'' is a persistent, dictionary-like object. The difference
with ``dbm'' databases is that the values (not the keys!) in a shelf
can be essentially arbitrary Python objects -- anything that the
pickle module can handle. This includes most class instances,
recursive data types, and objects containing lots of shared
sub-objects. The keys are ordinary strings

[...]
--
http://mail.python.org/mailman/listinfo/python-list


Re: QOTW [was Re: Attack a sacred Python Cow]

2008-07-28 Thread member thudfoo
On 28 Jul 2008 14:07:44 GMT, Steven D'Aprano
[EMAIL PROTECTED] wrote:
 On Sun, 27 Jul 2008 21:42:37 -0700, Russ P. wrote:

   +1 QOTW
  
   Do you realize what an insult that is to everyone else who has posted
   here in the past week?

  Actually I don't. I hadn't realised that when a person believes that
  somebody has made an especially clever, witty, insightful or fun remark,
  that's actually a put-down of all the other people whose remarks weren't
  quite as clever, witty, insightful or fun.

  But now that I've had this pointed out to me, why, I see insults
  everywhere! Tonight, my wife said to me that she liked my new shirt, so I
  replied What's the matter, you think my trousers are ugly?


  --
  Steven


 It is difficult to not offend the insult-sensitive.
--
http://mail.python.org/mailman/listinfo/python-list


Re: chm file for download?

2008-06-10 Thread member thudfoo
On 6/10/08, John Salerno [EMAIL PROTECTED] wrote:
 Is the chm doc file available for download from the Python website? I can't
  seem to find it. It would be nice to read through while I'm at work (where I
  don't have Python installed).

  Also, is it possible to use a chm file on Linux?

[...]

I am using xCHM on SuSE 10.2: iirc, there were components I had to
find in order to build it.

I just downloaded and installed kchmviewer (
http://www.kchmviewer.net/) without incident. My initial reaction is
that kchmviewer is better in at least two significant ways: it uses
the same number of lines per scroll wheel movement as other
applications (xCHM uses more, unconfigurable afaik); kchmviewer moves
the page to the indexed item in the page (xCHM just shows the the top
of the page leaving the user to locate the item in the page).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bring object 'out of' Class?

2008-06-01 Thread member thudfoo
On 6/1/08, Arnaud Delobelle [EMAIL PROTECTED] wrote:
 dave [EMAIL PROTECTED] writes:

[..]

  
  def deal_cards(self, num_of_hands, num):
  '''deals x amount of cards(num) to each hand'''
  for i in range(num_of_hands):
  handname = Hand('hand%d' % i)
  self.deal(handname, num)
  print '%s' % (handname.label), '\n', handname, '\n'
  


 You need to use a 'return' statement:


def deal_cards(self, num_of_hands, num):
'''deals x amount of cards(num) to each hand'''

hands = []

for i in range(num_of_hands):

newhand = Hand('hand%d' % i)
self.deal(newhand, num)
hands.append(newhand)

print '%s' % (handname.label), '\n', handname, '\n'

return Hand

Should be: return hands



  Then you can write:

   hands = deck.deal_cards(4, 5) # On fait une belotte?

[...]
--
http://mail.python.org/mailman/listinfo/python-list


Re: list object

2008-05-10 Thread member thudfoo
On 5/10/08, Gandalf [EMAIL PROTECTED] wrote:
 my manual contain chapter about lists with python. when i try to copy
  paste :

  li = [a, b, mpilgrim, z, example] (1)


  it i get this errore:

  TypeError: 'list' object is not callable

  i was wondering if their is  any special module I should import before
  i use this function

  i know i ask foolish questions it's my first day with python and i
  have experience only with PHP and javascript, so please be patient

  thanks

 --
  http://mail.python.org/mailman/listinfo/python-list


Remove the (1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: function that accepts any amount of arguments?

2008-04-24 Thread member thudfoo
On 4/24/08, Jonathan Gardner [EMAIL PROTECTED] wrote:
 On Apr 24, 5:28 am, malkarouri [EMAIL PROTECTED] wrote:
  
   What's wrong with raising ZeroDivisionError (not stopping the
   exception in the first place)?
  


 Because when I use your module, call avg (or mean) without args, I
  should see an error that says, Hey, you have to pass at least one
  value in!

  ZeroDivisonError doesn't mean that. It means I tried to divide by
  zero. Naively, I don't see where I was dividing by zero (because I
  don't remember how to calculate the mean---that's what your code was
  for.)

  ValueError does mean that I didn't pass the right kind of arguments
  in. ValueError(No items specified) would be even clearer. (Or maybe
  TypeError?)

  In general, any exception thrown should be meaningful to the code you
  are throwing it to. That means they aren't familiar with how your code
  works.


[source]|557 def average(n, *ints):
|... return (sum(ints)+n) / (len(ints) + 1)
|...
[source]|558 average (1,2,3)
558 2
[source]|559 average(3)
559 3
[source]|560 average(1,2)
560 1
[source]|561 average(0)
561 0
[source]|562 average()
---
TypeError Traceback (most recent call last)

/usr/share/doc/packages/python-dateutil/source/ipython console in module()

TypeError: average() takes at least 1 argument (0 given)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code to send RSS news by Sendmail

2008-03-16 Thread member thudfoo
On 3/15/08, Ulysse [EMAIL PROTECTED] wrote:
 Hello,

  I'm searching a code which allow you to parse each item in the RSS
  feed, get the news page of each item, convert it to text and send it
  by mail.

  Do you know if it exists ?

  Thanks

 --
  http://mail.python.org/mailman/listinfo/python-list


Feed parser:  http://feedparser.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Better grammar.txt

2008-03-06 Thread member thudfoo
On 3/5/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
   It includes three corrections to grammar.txt (imagnumber, xor_expr and
   and_expr) that I've reported.


 Make that four corrections. Add augop.

 --
  http://mail.python.org/mailman/listinfo/python-list

An error occurred while loading
http://www.martinrinehart.com/articles/python-grammar.html:
Unknown host www.martinrinehart.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble writing to database: RSS-reader

2008-01-23 Thread member thudfoo
On 1/23/08, Arne [EMAIL PROTECTED] wrote:
 On Jan 21, 11:25pm, Gabriel Genellina [EMAIL PROTECTED]
 wrote:
  En Mon, 21 Jan 2008 18:38:48 -0200, Arne [EMAIL PROTECTED] escribi�:
 
[...]


 This look very interesting! But it looks like that no documents is
 well-formed! I've tried several RSS-feeds, but they are eighter
 undefined entity or not well-formed. This is not how it should be,
 right? :)


Go to http://www.feedparser.org
Download feedparser.py
Read the documentation, at least.: you will find out a lot about
working with rss.

 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list