Re: Community (A Modest Proposal)

2010-06-13 Thread Someone Something
Here's the thing. Python has one of the nicest communities of most
software projects (except maybe ubuntu), try Perl or C. Unless you
completely know what you're talking about, have spent atleast 1/2 an
hour researching your problem, those guys will refrain from helping.

On Sun, Jun 13, 2010 at 1:45 PM, Terry Reedy tjre...@udel.edu wrote:
 On 6/13/2010 12:14 PM, rantingrick wrote:

 I have documented time and again the poor state of IDLE. The only
 responses i ever get are...

  Nobody uses IDLE
  Only a dumbass would use IDLE
  I have never used IDLE but i *know* nothing is wrong with it

 Perhaps you are listening selectively. I have said more than once on this
 list that I use IDLE, I like using it, it works for me, AND I would like it
 improved. When a student proposed that as part of a Google Summer of Code
 project, I (and others) encouraged him to go ahead, which he did. Any
 concrete effort you make to improve IDLE would be appreciated by me. There
 are issues on the tracker already.

 Terry Jan Reedy

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

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


Re: parse xml with invalid chars

2010-06-04 Thread Someone Something
What d'ya mean hang?

On Fri, Jun 4, 2010 at 10:16 AM, Roman Makurin dro...@gmail.com wrote:

 Hi all

 Last time i have a big problem, i need parse xml files
 which have invalid xml chars outside of CDATA and xml
 parser hangs everytime on such files. Is there any way
 to parse such files ???

 thanks

 --
 If you think of MS-DOS as mono, and Windows as stereo,
  then Linux is Dolby Digital and all the music is free...

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


Python vs. Fedora and CentOS

2010-05-29 Thread Someone Something
Redhat as always believed in (sorry if this offends anyone): Use legacy
stuff that works, we don't really give a flying hoot if the rest of the
world has moved on


 On Sat, May 29, 2010 at 6:55 PM, D'Arcy J.M. Cain da...@druid.net wrote:

 On Sat, 29 May 2010 11:43:29 -0700
 John Nagle na...@animats.com wrote:
 The major Red Hat based Linux distros are still shipping with Python
 2.4.
 
 Is anybody trying to do something about this?

 Other than not running Linux on our hosting server?  My ISP
 (http://www.Vex.Net) runs FreeBSD.  Linux is for the desktop.

 --
 D'Arcy J.M. Cain da...@druid.net |  Democracy is three wolves
 http://www.druid.net/darcy/|  and a sheep voting on
 +1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


My first project

2010-04-17 Thread Someone Something
This is my first large-scale (sort of) project in python. It is still under
daily development, but the core is pretty stable (although, I'm still adding
features). Here's the code: http://github.com/Poincare/PyEventLoop or
http://code.google.com/p/pyeventloop/
Tell me what you guys think of it (I'll be adding more examples by the end
of the day).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cross-platform coloured text in terminal

2010-04-17 Thread Someone Something
That sounds like a nice idea, try it out and see what you make of it. (It
may have been done before but probably not as a standalone module as it
doesn't require that much code)

On Sat, Apr 17, 2010 at 6:52 AM, Jonathan Hartley tart...@tartley.comwrote:

 On Apr 16, 5:59 pm, Lie Ryan lie.1...@gmail.com wrote:
  On 04/16/10 19:28, Jonathan Hartley wrote:
 
   I'm playing with ideas of what API to expose. My favourite one is to
   simply embed ANSI codes in the stream to be printed. Then this will
   work as-is on Mac and *nix. To make it work on Windows, printing could
   be done to a file0-like object which wraps stdout:
 
  The problem with that is you're simply reinventing ANSI.SYS device
 driver.
 
  An alternative API is you could override .__add__(), like so (completely
  untested):
 
  class Color(object):
 def __init__(self, color):
 self.color =  map_the_color(color)
 self.string = 
 def __add__(self, string):
 self.string += string
 return self
 def __str__(self):
 if terminal_can_do_ansi_color:
 return ansicolorescape(self.string, self.color)
 elif windows:
 syscalltocolor(self.color)
 print self.string
 syscalltocolor(reset the color)
 return 
 
  GREEN = Color('green')
  print GREEN + Great + Good
 
  you can even go a bit further and allow chained calls (again, completely
  untested, but you get the idea):
 
  class Color(object):
 def __init__(self, color):
 self.color =  map_the_color(color)
 self.stack = []
 def __add__(self, string):
 if isinstance(string, Color):
 # not a string, chain the calls
 self.stack.append((string.color, []]))
 else:
 # a string,
 self.stack[-1][1].append(string)
 return self
 def __radd__(self, string):
 self.stack.append([self.default, string])
 return self
 
 def __str__(self):
 if ansi_capable:
 return colorescape(format, string)
 elif windows:
 for format, string in self.stack:
 syscalltocolor(color)
 print string
 return 
 
  GREEN = Color('green')
  RED = Color('red')
 
  print Fairly + GREEN + Great + RED + Poor
 
  or something like that, and you will have an API that works
  transparently on all platforms. The downside is that you cannot call
  str(GREEN + foo) on windows.



 Hey Lie,

 Thanks heaps for the reply!

  The problem with that is you're simply reinventing ANSI.SYS device
 driver.

 I don't see that as a problem - in fact I think it's exactly my
 goal! :-)

 The difference is that the ANSI driver requires installation and a
 reboot on the end-user's computer, which is a fiddly and intrusive
 thing for a Python developer to achieve. Whereas doing the same job in
 a Python module is easy to use for the Python developer - they just
 import the module, maybe call an 'init()' function, and then the ANSI
 functionality works on all platforms.

 Your ideas about generating and chaining the ANSI code strings are
 great. I worry though, about intermingling the code that generates
 ANSI escape sequences with the code which makes them work on Windows.
 The problem is that then, only applications which use your ANSI-
 generation library will work on Windows. Whereas if these two things
 are kept separate, then applications which use any other ANSI-
 generation techniques, such as using 'termcolor', or manaully printing
 raw ANSI sequences, these can also all work on Windows too, simply by
 adding an import and an 'init()' call to the start of the application.

 Am I making sense? Many thanks for your thoughts.

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

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


Re: An open source AI research project

2010-04-17 Thread Someone Something
I would like to know more please. Does it have a website?
On Sat, Apr 17, 2010 at 4:03 AM, David Zhang david...@gmail.com wrote:

 Hello!

 I have started an open source project to develop human-level
 Artificial Intelligence, using Python and Java as programming
 language, OpenCog and OpenWonderland as basement. If you are
 interested in this,or want to know more, please feel free to give me a
 reply.

 Thanks!

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

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


Re: My first project

2010-04-17 Thread Someone Something
no one cares? :(

On Sat, Apr 17, 2010 at 8:41 AM, Someone Something fordhai...@gmail.comwrote:

 This is my first large-scale (sort of) project in python. It is still under
 daily development, but the core is pretty stable (although, I'm still adding
 features). Here's the code: http://github.com/Poincare/PyEventLoop or
 http://code.google.com/p/pyeventloop/
 Tell me what you guys think of it (I'll be adding more examples by the end
 of the day).

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


Re: CGI templating with python

2010-04-01 Thread Someone Something
Cheetah would work, but it would be a major pain to debug (I hate those 500
Server Error pages) something django (as mentioned above) or turbogears
(with Kid) would get you rolling quickly.

On Wed, Mar 31, 2010 at 8:38 PM, KB ke...@nekotaku.com wrote:

 Hi there,

 Years ago I wrote a LAMP app using python. I find I need a simple web
 data entry tool to store records (stock research) and when I enter a
 stock ticker, to pull up all the past research I have done. I am
 imagining fields like ticker, date, pulldown menus for various
 options, long text for comments etc..

 It's a very light weight application, so I was wondering if using
 something like Cheetah is the best way to do this?

 Or should I research Zope further or are there any other suggestions?

 Environment:
 - Python 2.5 (w/ MySQLdb)
 - MySQL 5.1
 - Windows Vista

 Many thanks in advance!
 --
 http://mail.python.org/mailman/listinfo/python-list

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


CPAN for python?

2010-03-30 Thread Someone Something
Hi,
I've learned python a few months ago but I still use Perl because of CPAN
and the tremendous amount of stuff that's already been done for you. is
there something like CPAN for python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Way to extract Numbers from String

2010-03-20 Thread Someone Something
Its an extremely bad idea to use regex for HTML. You want to change one tiny
little thing and you have to write the regex all over again. if its a
throwaway script, then go ahead.
2010/3/20 Luis M. González luis...@gmail.com

 On Mar 20, 12:04 am, Jimbo nill...@yahoo.com wrote:
  Hello
 
  I am trying to grab some numbers from a string containing HTML text.
  Can you suggest any good functions that I could use to do this? What
  would be the easiest way to extract the following numbers from this
  string...
 
  My String has this layout  I have commented what I want to grab:
  [CODE] /th
  td class=last43.200 /td
  td class=change indicator nowrap0.040
 /td
 
 td43.150 /td #
  I need to grab this number only
  td43.200 /td
 td43.130 /td #
  I need to grab this number only
  td43.290 /td
 td43.100 /td # I need to
  grab this number only
  td7,450,447 /td
  td class=middlea
 
 href=/asx/markets/optionPrices.do?
  by=underlyingCodeunderlyingCode=BHPexpiryDate=optionType=Options/
  a/td
  td class=middlea
 
 href=/asx/markets/warrantPrices.do?
  by=underlyingAsxCodeunderlyingCode=BHPWarrants  Structured
  Products/a/td
  td class=middlea
  href=/asx/markets/cfdPrices.do?
  by=underlyingAsxCodeunderlyingCode=BHPCFDs/a/td
  td class=middlea href=
 http://hfgapps.hubb.com/asxtools/
  Charts.aspx?
 
 TimeFrame=D6compare=comp_indexindicies=XJOpma1=20pma2=20asxCode=BHP
 img
  src=/images/chart.gif border=0 height=15 width=15/a
  /td
  tda
 href=/research/announcements/status_notes.htm#XDXD/a
  /td
  tda
 href=/asx/statistics/announcements.do?
  by=asxCodeasxCode=BHPtimeframe=Dperiod=WRecent/a
  /td
  /tr[/CODE]


 You should use BeautifulSoup or perhaps regular expressions.
 Or if you are not very smart, lik me, just try a brute force approach:

  for i in s.split(''):
for e in i.split():
if '.' in e and e[0].isdigit():
print (e)


 43.200
 0.040
 43.150
 43.200
 43.130
 43.290
 43.100
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: How to automate accessor definition?

2010-03-20 Thread Someone Something
Just initialize everything in the constructor, unless you have *really *good
reason not to do that.
On Sat, Mar 20, 2010 at 6:54 PM, Chris Rebert c...@rebertia.com wrote:

 On Sat, Mar 20, 2010 at 3:15 PM, kj no.em...@please.post wrote:
  I need to create a class solely for the purpose of encapsulating
  a large number of disparate data items.  At the moment I have no
  plans for any methods for this class other than the bazillion
  accessors required to access these various instance variables.
  (In case it matters, this class is meant to be a private helper
  class internal to a module, and it won't be subclassed.)

 If it's just a completely dumb struct-like class, you might consider
 something like:
 http://docs.python.org/library/collections.html#collections.namedtuple

  What is best practice for implementing this sort of class
  *succinctly* (i.e. without a lot of repetitive accessor code)?

 Is there any good reason you can't just use straight instance
 variables? Python ain't Java; vanilla, boilerplate accessor methods
 should almost always be avoided.

  Also, one more question concerning syntax.  Suppose that i represents
  an instance of this class.  Is it possible to define the class to
  support this syntax
 
   val = i.field
   i.field += 6
 
  ...rather than this one
 
   val = i.get_field()
   i.set_field(i.get_field() + 6)
 
  ?

 Yes, using the magic of the property() function:
 http://docs.python.org/library/functions.html#property

 Cheers,
 Chris
 --
 http://blog.rebertia.com
 --
 http://mail.python.org/mailman/listinfo/python-list

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


cpan for python?

2010-02-28 Thread Someone Something
Is there something like cpan for python? I like python's syntax, but I use
perl because of cpan and the tremendous modules that it has.
-- 
http://mail.python.org/mailman/listinfo/python-list


Just drawing lines and plotting points?

2010-01-26 Thread Someone Something
Hello,

I need a python library that makes drawing lines and plotting points (these
two things are the only things I need to do) easy. Or, how can I do
something like this with pygame? Basically, what I want to do is make
graphs. In pygame, since the coordinate system switches the x's and the y's
I would have to switch them again when I plot my points so my graphs look
okay. I hope this was enough info for me to get a good answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Open source projects

2009-12-11 Thread Someone Something
I'm a pretty okay python programmer and I really want to start developing
for an open source project. I'm looking for one that preferably deals with
networking and isn't as huge as twisted (that's just a preference, not
extremely important). Could anyone suggest any projects? I also know C,
Perl, Ruby and Java (java least preferred).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: editor with autocompletion

2009-12-05 Thread Someone Something
If you're actually going to release this, you shouldn't bundle it with
a preexisting text editor (IMHO) in case it goes out of development
and then you'll end up like DSL (damn small linux) did. In other words
either you get a text editor that's basically never going out of
development (emacs, not vim since its not that well grounded) and
write extensions for it, OR, write your own text editor. Second option
is very highly time consuming.

On 12/5/09, Fabio Zadrozny fabi...@gmail.com wrote:
 On Sat, Dec 5, 2009 at 5:19 AM, Siva B sivait...@gmail.com wrote:
 Hi All,
 Thanks for your reply.

 What I want is An Editor which can support Dynamic Languages with
 Autocomplete.

 I have my own language with some file extension (for ex: *.fs )
 I can add few keywords to editor, it should support autocomplte.
 thats what my idea.

 plz send me pointers (good if it is open source.)
 I have seen Komodo edit but it looks too big

 any help plz.


 I'd recommend notepad++ (for windows): should be easy to add simple
 completions. See:
 http://notepad-plus.sourceforge.net/uk/auto-completion-HOWTO.php

 If you know java and would like more options for your support (i.e.:
 IDE features) Eclipse could be an option (basic support for a language
 should be easy to add -- only when you want more advanced features the
 learning curve to add them becomes steeper, although that road will
 certainly be more work than adding support in notepad++ ).

 Cheers,

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

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


Re: Python Programming Challenges for beginners?

2009-11-27 Thread Someone Something
Codechef and all those algorithmic websites aren't very good for python
because, quite frankly, python is definitley slower than C or C++. You
should probably pick up a project on sourceforge or freshmeat if you feel
confident enough.

On Thu, Nov 26, 2009 at 10:24 PM, astral orange 457r0...@gmail.com wrote:

 Hi-

 I am reading the online tutorial along with a book I bought on Python.
 I would like to test out what I know so far by solving programming
 challenges. Similar to what O'Reilly Learning Perl has. I really
 enjoyed the challenges at the end of the chapter and it really help me
 test out if I was truly taking in the material like I should. Could I
 get some suggestions on resources? Is there anywhere where I can go
 online (for free or purchase) for programming problems? I am familiar
 with sites like Code Chef...etc...but at this stage that is not the
 right 'venue' for me. I mainly need challenges like the ones they have
 in Learning Perl.

 Thanks again for all the help,
 457r0
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Tax Calculator--Tkinter

2009-11-08 Thread Someone Something
I'm writing a simple tax calculator with Tkinter (just for fun).
Here's my current code:

from Tkinter import *;

class TaxCalc:
def __init__(self, root):

rate=Frame(root)
rate.pack()

income=Frame(root)
income.pack()

result=Frame(root)
result.pack()

self.rate=Entry(rate);
self.rate.pack();
self.enterr=Button(rate)
self.enterr['text']=Enter tax rate;
self.enterr['command']=self.getRate;
self.enterr.pack()

self.income=Entry(income);
self.income.pack();
self.enteri=Button(income);
self.enteri['text']=Enter income;
self.enterr['command']=self.getIncome;
self.enteri.pack();

self.result=Entry(result);
self.result.pack();
self.entere=Button(result);
self.entere['text']=Get result;
self.entere['command']=self.printResult;
self.entere.pack();

def getRate(self):
srate=self.rate.get();
print srate: , srate;

def getIncome(self):
sincome=self.income.get();
print sincome: , sincome;

def printResult(self):
if self.nrate is None | self.nincome is None:
print Clear everything and start again.;
print Don't fool around with me.;
else:
self.nresult=float(((100-self.nrate)/100)*self.nincome);
self.result.insert(END, str(self.nresult));

root=Tk()
MyCalc=TaxCalc(root)
root.mainloop()

The thing is, that even if I put 12 in the result text field, get
returns an empty string. How can I fix this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Spam Bot, broken pipe

2009-11-07 Thread Someone Something
I have a irc spam bot (only testing on my channel :P ) whose main loop is
the following:

privc=PRIVMSG +self.channel
while True:
 self.sock.send(privc= :SPAM SPAM SPAM!);
 time.sleep(2);

And it gives an error Broken Pipe.
How can I fix this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Spam Bot, broken pipe

2009-11-07 Thread Someone Something
I'm just testing it on my channel! I promise! Besides, I'm doing it to learn
about sockets! Please!


On Sat, Nov 7, 2009 at 8:07 PM, Krister Svanlund krister.svanl...@gmail.com
 wrote:

 On Sun, Nov 8, 2009 at 2:00 AM, Someone Something fordhai...@gmail.com
 wrote:
  I have a irc spam bot (only testing on my channel :P ) whose main loop is
  the following:
 
  privc=PRIVMSG +self.channel
  while True:
   self.sock.send(privc= :SPAM SPAM SPAM!);
   time.sleep(2);
 
  And it gives an error Broken Pipe.
  How can I fix this?

 By doing it right... unfortunaly I don't approve of spam and can
 therefor not tell you how to do that.

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


Re: Spam Bot, broken pipe

2009-11-07 Thread Someone Something
anyone?

On Sat, Nov 7, 2009 at 9:06 PM, Someone Something fordhai...@gmail.comwrote:



 I'm just testing it on my channel! I promise! Besides, I'm doing it to
 learn about sockets! Please!


 On Sat, Nov 7, 2009 at 8:07 PM, Krister Svanlund 
 krister.svanl...@gmail.com wrote:

 On Sun, Nov 8, 2009 at 2:00 AM, Someone Something fordhai...@gmail.com
 wrote:
  I have a irc spam bot (only testing on my channel :P ) whose main loop
 is
  the following:
 
  privc=PRIVMSG +self.channel
  while True:
   self.sock.send(privc= :SPAM SPAM SPAM!);
   time.sleep(2);
 
  And it gives an error Broken Pipe.
  How can I fix this?

 By doing it right... unfortunaly I don't approve of spam and can
 therefor not tell you how to do that.




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


continuous return?

2009-11-03 Thread Someone Something
I'm trying to write something related to IRC. The thing is, I have one
thread receiving and another sending. But, how can I keep the caller of the
recv() function informed about what was last received so that it can all be
printed out. But, I no idea how I can accomplish this. I was thinking about
getting one variable that was constantly updated with the latest line that
was recved and that the variable would be  a member of the class so other
functions/classes can access it
-- 
http://mail.python.org/mailman/listinfo/python-list


Regex

2009-10-20 Thread Someone Something
I'm trying to write a program that needs reg expressions in the following
way. If the user types in *something* that means that the asterixes can be
replaced by any string of letters. I haven't been able to find any reg
expression tutorials that I can understand. Help?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex

2009-10-20 Thread Someone Something
how can I implement this in python?

On Tue, Oct 20, 2009 at 8:06 PM, Steven D'Aprano 
ste...@remove.this.cybersource.com.au wrote:

 On Tue, 20 Oct 2009 16:20:14 -0700, Chris Rebert wrote:

  On Tue, Oct 20, 2009 at 3:16 PM, Someone Something
  fordhai...@gmail.com wrote:
  I'm trying to write a program that needs reg expressions in the
  following way. If the user types in *something* that means that the
  asterixes can be replaced by any string of letters. I haven't been able
  to find any reg expression tutorials that I can understand. Help?
 
  Sounds like you only need globbing
  (http://en.wikipedia.org/wiki/Glob_%28programming%29) as opposed to full
  regexes.
  Simple wildcard globbing can be trivially done by replacing the *s in
  the string with .*, like so:
 
  *something* === .*something.*

 Or just use the glob and fnmatch modules.


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

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


Re: Threading from a class

2009-10-17 Thread Someone Something
anyone?

On Sat, Oct 17, 2009 at 4:26 PM, Someone Something fordhai...@gmail.comwrote:

 I'm trying to write a IRC client that has to have a method inside class
 Client that has to start a new thread that goes to run() which is in the
 same class. I'm not really understanding all the threading tutorials i've
 found. Can someone help?

 p.s. trying to use the threading module, not the thread module.

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


Multiple files

2009-10-17 Thread Someone Something
I was trying to write a program with just one class and it was working fine.
Then, I seperated that class into two different files and made the objects
and called the methods in a third (client.py IO.py main.py). Now, when I use
the command:

python client.py IO.py main.py

Nothing prints. I think its only interpreting client.py (the objects are
declared in main.py)

How can I fix this?
-- 
http://mail.python.org/mailman/listinfo/python-list


One class one file?

2009-10-16 Thread Someone Something
I'm trying write a program that's going to be more than 100 lines or so but
I need it all in one class. Is there a painless way to have one class in two
files?
-- 
http://mail.python.org/mailman/listinfo/python-list


What do I do now?

2009-10-11 Thread Someone Something
I've been programming since about 3 years, and come to think of it never
written anything large. I know a few languages: c, python, perl, java. Right
now, I just write little IRC bots that basically don't do anything.

I have two questions:

1) What should I start programming (project that takes 1-2 months, not very
short term)?
2) Whtat are some good open source projects I can start coding for?


I'd rather not just waste time programming little useless things all the
time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Multidimensional arrays/lists

2009-09-27 Thread Someone Something
I'm trying to write a little tic-tac-toe program I need a array/list such
that I can represent the tic tac toe board with an x axis and y axis and i
can access each square to find out whether there is an X or an O. I have
absolutely no idea how to do this in python and I really, really, don't want
to do this is C.
-- 
http://mail.python.org/mailman/listinfo/python-list


IRC bot

2009-09-13 Thread Someone Something
Im trying to write an IRC bot just for fun (in python of course). Here's my
current code:

  1 #!/usr/local/bin/python
  2 import time
  3 import socket
  4
  5 def message (x, channel,s):
  6 y=PRIVMSG+ + channel+ :+x
  7 s.send(y);
  8 host=irc.freenode.net;
  9 port=6667;
 10 size=1024;
 11 channel=#dhaivatrocks;
 12 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
 13 s.connect((host,port));
 14 s.send(NICK PoincareBot);
 15 s.send(USER  PoincareBot 8 *  : Paul Mutton);
 16 time.sleep(5);
 17 s.send(JOIN #dhaivatrocks);
 18 s.send(PRIVMSG #dhaivatrocks :Hello everybody!
 19 while True:
 20 pass;
 21
What I don't understand is that it doesn't display any messages or show a
new message login on my IRC client. What's wrong with my code?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IRC bot

2009-09-13 Thread Someone Something
Anyone?

On Sun, Sep 13, 2009 at 3:58 PM, Someone Something fordhai...@gmail.comwrote:

 Im trying to write an IRC bot just for fun (in python of course). Here's
 my current code:

   1 #!/usr/local/bin/python
   2 import time
   3 import socket
   4
   5 def message (x, channel,s):
   6 y=PRIVMSG+ + channel+ :+x
   7 s.send(y);
   8 host=irc.freenode.net;
   9 port=6667;
  10 size=1024;
  11 channel=#dhaivatrocks;
  12 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
  13 s.connect((host,port));
  14 s.send(NICK PoincareBot);
  15 s.send(USER  PoincareBot 8 *  : Paul Mutton);
  16 time.sleep(5);
  17 s.send(JOIN #dhaivatrocks);
  18 s.send(PRIVMSG #dhaivatrocks :Hello everybody!
  19 while True:
  20 pass;
  21
 What I don't understand is that it doesn't display any messages or show a
 new message login on my IRC client. What's wrong with my code?


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


Re: IRC bot

2009-09-13 Thread Someone Something
Thanks a lot!

On Sun, Sep 13, 2009 at 4:29 PM, MRAB pyt...@mrabarnett.plus.com wrote:

 Someone Something wrote:

 Im trying to write an IRC bot just for fun (in python of course). Here's
 my current code:

  1 #!/usr/local/bin/python
  2 import time
  3 import socket
  4
  5 def message (x, channel,s):
  6 y=PRIVMSG+ + channel+ :+x
  7 s.send(y);
  8 host=irc.freenode.net http://irc.freenode.net;
  9 port=6667;
  10 size=1024;
  11 channel=#dhaivatrocks;
  12 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
  13 s.connect((host,port));
  14 s.send(NICK PoincareBot);
  15 s.send(USER  PoincareBot 8 *  : Paul Mutton);
  16 time.sleep(5);
  17 s.send(JOIN #dhaivatrocks);
  18 s.send(PRIVMSG #dhaivatrocks :Hello everybody!
  19 while True:
  20 pass;
  21
 What I don't understand is that it doesn't display any messages or show a
 new message login on my IRC client. What's wrong with my code?

 You probably need to put some sort of line ending on what you send, eg
 \n or \r\n. Also, it's better to use 'sendall' insetad of 'send'.

 BTW, you don't need to put a semicolon on the end of the lines.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Project euler no. 3

2009-09-12 Thread Someone Something
Project euler (in case you don't know: projecteuler.net)

I'm trying to do the third one and here's my current code:

  1 def checkPrime (x):
  2 factors=2;
  3 while factors=x:
  4 if x==factors:
  5 return True;
  6 elif x%factors==0:
  7 return False;
  8 elif x%factors!=0:
  9 factors=factors+1;
 10
 11 factorl=[];
 12 factors=600851475142;
 13
 14 while factors != 1:
 15 if 600851475143%factors==0:
 16 if checkPrime(factors)==True:
 17 print factors;
 18 else:
 19 factors=factors-1;
 20
 21 else:
 22 factors=factors-1;
 23

And it just gets frozen when I run it. I put a

print Loop completed

in one of the loops and it showed up just fine. So, there are two
possibilities:
1. Its looping in the trillions and taking a while
2. I have a forever loop somewhere
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project euler no. 3

2009-09-12 Thread Someone Something
But, I'm returning true or false right?

On Sat, Sep 12, 2009 at 11:32 AM, MRAB pyt...@mrabarnett.plus.com wrote:

 Someone Something wrote:

 Project euler (in case you don't know: projecteuler.net 
 http://projecteuler.net)

 I'm trying to do the third one and here's my current code:

  1 def checkPrime (x):
  2 factors=2;
  3 while factors=x:
  4 if x==factors:
  5 return True;
  6 elif x%factors==0:
  7 return False;
  8 elif x%factors!=0:
  9 factors=factors+1;


 You're not returning 'factors', so the function will return None.


   10
  11 factorl=[];
  12 factors=600851475142;
  13
  14 while factors != 1:
  15 if 600851475143%factors==0:
  16 if checkPrime(factors)==True:
  17 print factors;
  18 else:
  19 factors=factors-1;
  20
  21 else:
  22 factors=factors-1;
  23

 And it just gets frozen when I run it. I put a

 print Loop completed

 in one of the loops and it showed up just fine. So, there are two
 possibilities:
 1. Its looping in the trillions and taking a while
 2. I have a forever loop somewhere


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

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


Re: Project euler no. 3

2009-09-12 Thread Someone Something
Anyone?

On Sat, Sep 12, 2009 at 11:46 AM, Someone Something fordhai...@gmail.comwrote:

 But, I'm returning true or false right?

 On Sat, Sep 12, 2009 at 11:32 AM, MRAB pyt...@mrabarnett.plus.com wrote:

 Someone Something wrote:

 Project euler (in case you don't know: projecteuler.net 
 http://projecteuler.net)

 I'm trying to do the third one and here's my current code:

  1 def checkPrime (x):
  2 factors=2;
  3 while factors=x:
  4 if x==factors:
  5 return True;
  6 elif x%factors==0:
  7 return False;
  8 elif x%factors!=0:
  9 factors=factors+1;


 You're not returning 'factors', so the function will return None.


   10
  11 factorl=[];
  12 factors=600851475142;
  13
  14 while factors != 1:
  15 if 600851475143%factors==0:
  16 if checkPrime(factors)==True:
  17 print factors;
  18 else:
  19 factors=factors-1;
  20
  21 else:
  22 factors=factors-1;
  23

 And it just gets frozen when I run it. I put a

 print Loop completed

 in one of the loops and it showed up just fine. So, there are two
 possibilities:
 1. Its looping in the trillions and taking a while
 2. I have a forever loop somewhere


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



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


Re: Podcast catcher in Python

2009-09-12 Thread Someone Something
C shouldn't be very hard.
You just get the url of the file you want to connect to, then just use the
normal connect sequence and read the file and print it out to the UNIX
shell, then at the unix shell, just pipe it to an MP3. Or you could just do
it with FILE *.
On Sat, Sep 12, 2009 at 4:37 PM, Chuck galois...@gmail.com wrote:

 On Sep 11, 9:54 pm, Chris Rebert c...@rebertia.com wrote:
  On Fri, Sep 11, 2009 at 7:43 PM, Chuck galois...@gmail.com wrote:
   Does anyone know how I should read/download the mp3 file, and how I
   should write/save it so that I can play it on a media player such as
   Windoze media player?  Excuse my ignorance, but I am a complete noob
   at this.  I downloaded the mp3, and I got a ton of hex, I think, but
   it could've been unicode.
 
  urllib.urlretrieve():
 http://docs.python.org/library/urllib.html#urllib.urlretrieve
 
  Cheers,
  Chris

 Thanks Chris!  I will play around with this.
 --
 http://mail.python.org/mailman/listinfo/python-list

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