Re: problems with shelve(), collections.defaultdict, self

2012-02-11 Thread 7stud
On Feb 11, 10:56 am, Ian Kelly wrote: > On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote: > > class Dog(dict): > > >    def __missing__(self): > >        return 0 > > Sorry, that should have been: > > class Dog(dict): > >     def __missing__(self, key): >         return 0 > > Cheers, > Ian Than

Re: problems with shelve(), collections.defaultdict, self

2012-02-10 Thread 7stud
On Feb 10, 7:52 pm, 7stud <7s...@excite.com> wrote: I don't know if this helps, but I notice when I initially do this: shelve.open('data22') the file is saved as 'data22.db'. But on subsequent calls to shelve.open(), if I use the file name 'data22.db&

Re: problems with shelve(), collections.defaultdict, self

2012-02-10 Thread 7stud
On Feb 10, 7:48 pm, 7stud <7s...@excite.com> wrote: > > But I cannot get a class that inherits from collections.defaultdict to > shelve itself: > > import collections as c > import shelve > > class Dog(c.defaultdict): >     def __init__(self): >         super().

problems with shelve(), collections.defaultdict, self

2012-02-10 Thread 7stud
The following code demonstrates that a collections.defaultdict is shelve worthy: import shelve import collections as c dd = c.defaultdict(int) dd["Joe"] = 3 print(dd) my_shelve = shelve.open('data.shelve') my_shelve['strike_record'] = dd my_shelve.close() my_shelve = shelve.open('data.shelve'

Re: installing lxml ?

2009-11-11 Thread 7stud
On Nov 11, 5:59 pm, 7stud wrote: > > 1) Maybe the installation instructions for mac osx should read: > > > Installation Instructions > > > MAC OS X: > We're not sure how mac osx works with easy_install.  Apple's system > installations of lib

Re: installing lxml ?

2009-11-11 Thread 7stud
On Nov 11, 1:37 pm, Terry Reedy wrote: > 7stud wrote: > > On Nov 11, 7:37 am, "Diez B. Roggisch" wrote: > >> And third, > >> there are limits to what extend one can anticipate the ineptness of > > Calling you inept was unnecessary, but > >

Re: installing lxml ?

2009-11-11 Thread 7stud
On Nov 11, 7:37 am, "Diez B. Roggisch" wrote: > And third, > there are limits to what extend one can anticipate the ineptness of > others to read. The page you cite from starts with: > >    For special installation instructions regarding MS Windows and > MacOS-X, see below. > > And below you find

Re: installing lxml ?

2009-11-11 Thread 7stud
On Nov 11, 6:31 am, Jussi Piitulainen wrote: > 7stud writes: > > I'm trying to install lxml, but I can't figure out the installation > > instructions.  Here: > ... > > My os is mac os x 10.4.11.   But this: > > > STATIC_DEPS=true easy_install lxml

installing lxml ?

2009-11-11 Thread 7stud
I'm trying to install lxml, but I can't figure out the installation instructions. Here: http://codespeak.net/lxml/installation.html it says: 1) Get the easy_install tool. Ok, I went to the easy_install website, downloaded, and installed it. The last two lines of the output during installation

Re: Function to apply superset of arguments to a function

2009-09-09 Thread 7stud
On Sep 9, 10:45 am, Andrey Fedorov wrote: > Hi all, > > I've written a function [1] called apply_some which takes a set of > keywords arguments, filters only those a function is expecting, and > calls the function with only those arguments. This is meant to > suppress TypeErrors - a way to abstrac

Re: Something confusing about non-greedy reg exp match

2009-09-07 Thread 7stud
On Sep 6, 8:46 pm, "gburde...@gmail.com" wrote: > If I do this: > > import re > a=re.search(r'hello.*?money',  'hello how are you hello funny money') > > I would expect a.group(0) to be "hello funny money", since .*? is a > non-greedy match. But instead, I get the whole sentence, "hello how > are

Re: simple string question

2009-09-06 Thread 7stud
On Sep 6, 11:29 pm, "jwither" wrote: > Given a string (read from a file) which contains raw escape sequences, > (specifically, slash n), what is the best way to convert that to a parsed > string, where the escape sequence has been replaced (specifically, by a > NEWLINE token)? > > James Withers 1

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:23 am, 7stud wrote: > On Sep 6, 1:14 am, 7stud wrote: > > > > > On Sep 5, 5:29 pm, per wrote: > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > &g

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:14 am, 7stud wrote: > On Sep 5, 5:29 pm, per wrote: > > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > >

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 5, 5:29 pm, per wrote: > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > > >> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote: > > >> > I'm trying to efficiently "split" strings based on wha

Re: Sending email

2009-08-30 Thread 7stud
On Aug 28, 8:18 am, Fencer wrote: > 7stud wrote: > > [snip] > > Thanks for your reply. After consulting the sysadmins here I was able to > get it to work. > > - Fencer Ok, but how about posting your code so that a future searcher will not be left screaming, "

Re: Sending email

2009-08-28 Thread 7stud
On Aug 28, 2:37 am, Fencer wrote: > Hello, I'm using Python version 2.6.2 and I discovered it has built-in > libraries for sending email (imports smtplib and email). On the web I > discovered how to send mail through smtp.gmail.com: > > mail_server = smtplib.SMTP() > > mail_server.connect('smtp.gm

Re: print() and unicode strings (python 3.1)

2009-08-26 Thread 7stud
On Aug 25, 6:34 am, Nobody wrote: > The underlying OS primitive can only handle bytes. If you read or write a > (unicode) string, Python needs to know which encoding is used. For Python > file objects created by the user (via open() etc), you can specify the > encoding; for those created by the ru

Re: Need help with Python scoping rules

2009-08-26 Thread 7stud
On Aug 25, 7:26 pm, Dave Angel wrote: > Stephen Fairchild wrote: > > You are trying to run code in a class that does not exist yet. > > > def Demo(): > >     def fact(n): > >         if n < 2: > >             return 1 > >         else: > >             return n * fact(n - 1) > >     return type("De

Re: Need help with Python scoping rules

2009-08-25 Thread 7stud
On Aug 25, 12:11 pm, John Posner wrote: > Diez said: > > > > > Classes are not scopes. > > > So the above doesn't work because name resolution inside functions/methods > > looks for local variables first, then for the *global* scope. There is no > > class-scope-lookup. > > Buthttp://docs.python.or

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread 7stud
On Aug 24, 10:09 pm, Ned Deily wrote: > In article > , > > > > 7stud wrote: > > On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > > > I can't figure out a way to programatically set the encoding for > > > > sys.stdout. So where

Re: best way to display photos

2009-08-24 Thread 7stud
On Aug 24, 8:01 pm, Paul Rubin wrote: > samwyse writes: > > My big question is, what's the > > best way to display the photos.  I've used PIL in the past, but IIRC > > it uses an external program.  Pygame is the next obvious choice, but > > like PIL it requires an ad

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > I can't figure out a way to programatically set the encoding for > > sys.stdout.  So where does that leave me? > > You should be setting the terminal encoding administratively, not > programmatically. > The terminal encoding has always been utf-8.

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 12:19 pm, Stefan Behnel wrote: > 7stud wrote: > > python 3.1 won't let me > > explicitly encode my unicode string > > Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail. > As you should be able to see in the python 3.1 example I

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 9:56 am, "Martin v. Löwis" wrote: > > I don't understand why I'm getting an encode error in python 3.1. > > The default encoding is not relevant here at all. Look at > sys.stdout.encoding. > > Regards, > Martin Hi, Thanks for the response. I get US-ASCII for both 2.6 and 3.1: ===pyt

print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
==python 2.6 == import sys print sys.getdefaultencoding() s = u"\u20ac" print s.encode("utf-8") $ python2.6 1test.py ascii € =python 3.1 === import sys print(sys.getdefaultencoding()) s = "€" print(s.encode("utf-8")) print(s) $ python3.1 1test.py utf-8 b'\xe2\x82\xac' Tra

Re: Monkeypatching an object to become callable

2009-08-09 Thread 7stud
On Aug 9, 1:02 pm, Nikolaus Rath wrote: > Hi, > > I want to monkeypatch an object so that it becomes callable, although > originally it is not meant to be. (Yes, I think I do have a good reason > to do so). > > But simply adding a __call__ attribute to the object apparently isn't > enough, and I d

Re: Upgrade Python on a Mac

2009-03-30 Thread 7stud
On Mar 3, 4:01 am, Graham Dumpleton wrote: > On Mar 3, 8:53 am, Rey Bango wrote: > > > Hi, > > > I'd like to upgrade the installed version of Python that came standard > > on OS X (Leopard) with either 2.6.1 or 3.0.1. Before I stick my foot > > in it, I just wanted to get a better understanding o

Re: exception in urllib2

2009-02-01 Thread 7stud
On Feb 1, 3:34 am, asit wrote: > I hv been developing a link scanner. Here the objective is to > recursively scan a particular web site. > > During this, my script methttp://images.google.co.in/imghp?hl=en&tab=wi > and passed it to the scan function, whose body is like this.. > > def scan(site): >

Re: exception in urllib2

2009-02-01 Thread 7stud
On Feb 1, 3:34 am, asit wrote: > I hv been developing a link scanner. Here the objective is to > recursively scan a particular web site. > > During this, my script methttp://images.google.co.in/imghp?hl=en&tab=wi > and passed it to the scan function, whose body is like this.. > > def scan(site): >

Re: New to python, open source Mac OS X IDE?

2009-01-28 Thread 7stud
On Jan 27, 6:07 pm, Burukena wrote: > On 1/27/09 8:44 PM, James Stroud wrote: > > > joseph.a.mar...@gmail.com wrote: > >> Greetings! I've heard enough raving about Python, I'm going to see for > >> myself what all the praise is for! > > >> I'm on a Mac. I use Netbeans for Java, PHP, and C if neede

Re: Start Python at client side from web app

2009-01-21 Thread 7stud
On Jan 21, 1:10 am, Thomas Guettler wrote: > Hi, > > I want to start Python at the client side from a web application. The > app is an intranet application, and all client PCs are under our control (we > can install software on them). > > But I don't want to update the installation too often. Here

Re: output problem

2009-01-18 Thread 7stud
On Jan 16, 8:24 am, "Jean-Paul VALENTIN" wrote: > Feature? the output of below Hello program he0.py started from command > line looks as follows: > F:\prompt>he0.py > Hello > F:\prompt> > > 'Hello' was sent with sys.stdout.write, so "without newline". > But why cannot be output (more logically): >

Re: smtplib "authentication required" error

2008-05-17 Thread 7stud
On May 17, 12:18 pm, cher <[EMAIL PROTECTED]> wrote: > Hey, > > Don't know if you can help, but I'm trying to import archived messages > from Thunderbird into my gmail account and keep getting these types of > errors.  I am using the GML program to help incorporate, but the SMTP > server is not bei

Re: Cookies and CookieJar

2008-05-17 Thread 7stud
Larry Bates wrote: > I'm struggling with a project using mechanize and cookies to screen scape a > website. The site requires a client created cookie for authentication. Are you sure that is correct? As far as I know, the usual course of events is for a site to set a cookie header in the respons

Re: Cookies and CookieJar

2008-05-17 Thread 7stud
On May 16, 9:21 am, Larry Bates <[EMAIL PROTECTED]> wrote: > I'm struggling with a project using mechanize and cookies to screen scape a > website.  The site requires a client created cookie for authentication.  Below > is the code I'm attempting to use with the traceback I'm getting: > >  >>> impo

Re: write to specific line in file?

2008-05-16 Thread 7stud
globalrev wrote: > i ahve a program that takes certain textsnippets out of one file and > inserts them into another. > > problem is it jsut overwrites the first riow every time. > > i want to insert every new piece of text into the next row. > so: > 1. how do i write to a new line every time i writ

Re: downloading a link with javascript in it..

2008-05-12 Thread 7stud
On May 12, 4:59 pm, 7stud <[EMAIL PROTECTED]> wrote: > On May 12, 1:54 pm, Jetus <[EMAIL PROTECTED]> wrote: > > > I am able to download this page (enclosed code), but I then want to > > download a pdf file that I can view in a regular browser by clicking > > on

Re: downloading a link with javascript in it..

2008-05-12 Thread 7stud
On May 12, 1:54 pm, Jetus <[EMAIL PROTECTED]> wrote: > I am able to download this page (enclosed code), but I then want to > download a pdf file that I can view in a regular browser by clicking > on the "view" link. I don't know how to automate this next part of my > script. It seems like it uses J

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
On May 11, 5:50 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > bc90021 wrote: > > You are a perfect example of exactly what I was talking about, and why > > the Python community is such a poor one. > > I though you were treated quite fairly all things considered.   (You > started the personal attacks

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
On May 11, 2:11 pm, bc90021 <[EMAIL PROTECTED]> wrote: > [CUT] > > > I have in no way assumed that you are stupid.  I have tried to help you > > formulate your problem better so that people on the list can help you. > > I believe I have done so respectfully, with the aim of introducing you > > to t

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
On May 11, 2:01 pm, 7stud <[EMAIL PROTECTED]> wrote: > On May 11, 1:28 pm, bc90021 <[EMAIL PROTECTED]> wrote: > > > > > > ...and the exact error message was? > > > > Here is a tip: if you want people to help you, then you have to help > > >

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
On May 11, 1:28 pm, bc90021 <[EMAIL PROTECTED]> wrote: > > ...and the exact error message was? > > > Here is a tip: if you want people to help you, then you have to help > > them to help you.  Personally, I wouldn't respond to anymore of your > > questions because you seem incapable of posting the

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
bc90021 wrote: > Hi All, > > Thanks in advance for any and all help! > > I have this code: > > g = open(fileName, 'a') > > where fileName is defined before the line it's used in. It works fine > when I use it outside a thread class. > > When I put the same line in a thread class, it no longer work

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread 7stud
On May 11, 12:42 pm, bc90021 <[EMAIL PROTECTED]> wrote: > > It's difficult to know what's wrong with the code you posted because: > > > * it is not self-contained: otherFile, fileName, pattern are names > >   which you do not define; > > > * the IOError you reported earlier can't arise as a result

Re: Problem with custom events in wxpython

2008-05-11 Thread 7stud
On May 11, 7:23 am, Jimmy <[EMAIL PROTECTED]> wrote: > hi, all > > I'm having a problem with creating custom events in wxpython. > > I have a class A handling some data processing work and another class > B of GUI matter. I need GUI to display information when data in A is > updated. > I know cutom

Re: Is using range() in for loops really Pythonic?

2008-05-10 Thread 7stud
On May 10, 8:19 pm, John Salerno <[EMAIL PROTECTED]> wrote: > I know it's popular and very handy, but I'm curious if there are purists > out there who think that using something like: > > for x in range(10): >     #do something 10 times > > is unPythonic. The reason I ask is because the structure o

Re: where do I begin with web programming in python?

2008-05-02 Thread 7stud
On May 1, 3:25 pm, jmDesktop <[EMAIL PROTECTED]> wrote: > I have been to the main python site, but am still confused.  I have > been using .net, so it may be obvious how to do this to everyone > else.  I am aware there are various frameworks (Django, Pylons, etc.), > but I would like to know how to

Re: Inheritance confusion

2008-04-19 Thread 7stud
On Apr 19, 12:37 am, Hook <[EMAIL PROTECTED]> wrote: > Hi, > > I'm having a problem with multiple inheritance - it's clearly something > I've missed, but the web pages and books that I've consulted aren't > helping, so I'll throw myself on the mercy and collective wisdom of > Usenet! > > I've got 4

Re: How to print a unicode string?

2008-04-18 Thread 7stud
On Apr 18, 6:36 pm, 7stud <[EMAIL PROTECTED]> wrote: > On Apr 18, 5:38 pm, [EMAIL PROTECTED] wrote: > > > > > I'd like to print out a unicode string. > > > I'm running Python inside Emacs, which understands utf-8, so I want to > > force Python

Re: How to print a unicode string?

2008-04-18 Thread 7stud
On Apr 18, 5:38 pm, [EMAIL PROTECTED] wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. > > From what I've googled, I think I need to set my locale. I don't > understand how. > > im

Re: Tkinter, image not appearing in function but without function

2008-04-13 Thread 7stud
On Apr 13, 11:12 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: > > why is the first program not working? when i click the screen the map > > is not appearing. > > > the second program works. > > > from Tkinter import * > > > master =

Re: urllib2 Basic authentication, what am I doing wrong?

2008-04-13 Thread 7stud
Michel Bouwmans wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hey everybody, > > I'm having a little problem with urllib2 and Basic HTTP authentication. > > I have the following code: > > auth = urllib2.HTTPPasswordMgrWithDefaultRealm() > auth.add_password(None, 'https://webmail.osg-

Re: Confused about Boost.Python & bjam

2008-04-12 Thread 7stud
On Apr 12, 4:53 am, Till Kranz <[EMAIL PROTECTED] goettingen.de> wrote: > Hi, > > I tried to get started with Boost.Python. unfortunately I never used the > bjam build system before. As it is explained in the documentation I tried > to adapt the the files form the examples directory. I copied 'Jamr

Re: Tkinter, a lot of buttons, make prog shorter?

2008-04-06 Thread 7stud
On Apr 6, 8:50 pm, [EMAIL PROTECTED] wrote: > should i not use self. in Clean() and Calculate() either? > You probably shouldn't be using classes at all. When you are trying to learn the basics of a language, you don't want to complicate things further with classes. Copying a program off the int

Re: Tkinter, a lot of buttons, make prog shorter?

2008-04-06 Thread 7stud
On Apr 6, 4:12 pm, 7stud <[EMAIL PROTECTED]> wrote: > You said you were an experienced programmer, but you keep posting code > with the same mistakes over and over again.  Why are you attaching the > buttons to self? Remember this: > Another thing you should be aware of: se

Re: Tkinter, a lot of buttons, make prog shorter?

2008-04-06 Thread 7stud
On Apr 6, 1:59 pm, [EMAIL PROTECTED] wrote: > is there anyway to make this shorter? i hate having these big blocks > of similar-looking code, very unaesthetic. > maybe doesnt matter good-code-wise? > anyway can i make some function that makes this shorter? > like put the etiquettes on the button fr

Re: Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread 7stud
> > Just like the message says: You are trying to use `str` (on the right hand > > side of the assignment) before anything is bound to that name. > > > Ciao, > >         Marc 'BlackJack' Rintsch > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be acc

Re: Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread 7stud
On Apr 5, 1:55 pm, 7stud <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > using tkinter and python i now have a small App (that will hopefully > > soon be a fully functioning calculator) where u can push buttons and > > the corresponding number or operator is

Re: Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread 7stud
[EMAIL PROTECTED] wrote: > using tkinter and python i now have a small App (that will hopefully > soon be a fully functioning calculator) where u can push buttons and > the corresponding number or operator is shown. > > when u press 1, "1" appears on the screen, pres + and "+" appears etc. > > at

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread 7stud
On Apr 5, 12:02 am, [EMAIL PROTECTED] wrote: > am i not doing that then? did u look at the code? where do i add the > bind if this: > btnDisplay = Button(self, text="1", command=self.Display) >         btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > is not enough? > > def Display(self, event_o

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread 7stud
[EMAIL PROTECTED] wrote: > > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-04 Thread 7stud
On Apr 4, 7:06 pm, [EMAIL PROTECTED] wrote: > 1st question: > > when i run this program 1 will be printed into the interpreter when i > run it BUT without me clicking the actual button. > when i then click the button "1", nothing happens. > > obv i dont want any output when i dont push the button b

Re: Is there any way to say ignore case with "in"?

2008-04-04 Thread 7stud
On Apr 4, 2:43 pm, [EMAIL PROTECTED] wrote: > Is there any way in python to say > >     if string1 in string2: >         > > ignoring the case of string1 and string2? > > I know I could use:- > >     if lower(string1) in lower(string2): >         > > but it somehow feels there ought to be an easi

Re: Parsing HTML?

2008-04-03 Thread 7stud
On Apr 3, 12:39 am, [EMAIL PROTECTED] wrote: > BeautifulSoup does what I need it to.  Though, I was hoping to find > something that would let me work with the DOM the way JavaScript can > work with web browsers' implementations of the DOM.  Specifically, I'd > like to be able to access the innerHTM

Re: class / module introspection?

2008-04-02 Thread 7stud
On Apr 2, 1:27 pm, Brian Munroe <[EMAIL PROTECTED]> wrote: > On Apr 2, 12:07 pm, Brian Munroe <[EMAIL PROTECTED]> wrote: > > > > > This gives me ['system1','system2'] - which I can then use __import__ > > on. > > Addendum, thanks Bruno! > > I also required the helper function (my_import) from the P

Re: XML Parsing

2008-04-01 Thread 7stud
On Apr 1, 1:42 pm, Alok Kothari <[EMAIL PROTECTED]> wrote: > Hello, >           I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > > # 3 h

Re: BeautiflSoup -- getting all the attributes of a tag?

2008-04-01 Thread 7stud
On Apr 1, 5:25 pm, 7stud <[EMAIL PROTECTED]> wrote: > You can treat a tag like a dictionary to obtain a specific attribute: > > import BeautifulSoup as bs > > html = "hello" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > print div &

BeautiflSoup -- getting all the attributes of a tag?

2008-04-01 Thread 7stud
You can treat a tag like a dictionary to obtain a specific attribute: import BeautifulSoup as bs html = "hello" doc = bs.BeautifulSoup(html) div = doc.find("div") print div print div["x"] --output:-- a But you can't iterate over a tag to get all the attributes: import BeautifulSoup as bs htm

Re: Looking for indent advice howto in emacs python-mode

2008-03-31 Thread 7stud
On Mar 31, 10:32 am, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > Here's what I want to do: > > if ( ( v == 1 ) >    or ( v == 2 ) >    or ( v == 3 ) ): >      pass > python indenting = 4 spaces -- http://mail.python.org/mailman/listinfo/python-list

Re: python persistence

2008-03-31 Thread 7stud
On Mar 31, 5:31 pm, [EMAIL PROTECTED] wrote: > Can you have a Python object stored entirely on disk? import cPickle as cp class Dog(object): def __init__(self, name): self.name = name d = Dog("Spot") f = open("data.txt", "w") cp.dump(d, f) f.close() f = open("data.txt") stored_obj

Re: problem with CGIHTTPServer

2008-03-28 Thread 7stud
On Mar 28, 10:12 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 28 Mar 2008 12:38:45 -0300, 7stud <[EMAIL PROTECTED]>   > escribió: > > > After I start the server script, load the html page in my browser, and > > click on the link, I ge

problem with CGIHTTPServer

2008-03-28 Thread 7stud
1) I have this simple cgi server: import CGIHTTPServer import BaseHTTPServer class MyRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler): cgi_directories = ['/my_cgi_scripts'] server = BaseHTTPServer.HTTPServer( ('', 8111), MyRequestHandler ) server.serve_forever() 2) I

Re: Do any of you recommend Python as a first programming language?

2008-03-22 Thread 7stud
On Mar 22, 3:34 pm, bsoist <[EMAIL PROTECTED]> wrote: > On Mar 22, 12:40 pm, jmDesktop <[EMAIL PROTECTED]> wrote: > > > For students 9th - 12th grade, with at least Algebra I.  Do you think > > Python is a good first programming language for someone with zero > > programming experience?  Using Linu

Re: Removal of tkinter from python 3.0? [was: Fate of the repr modulein Py3.0]

2008-03-20 Thread 7stud
On Mar 20, 8:42 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message > > news:[EMAIL PROTECTED] > | "Daniel Fetchinson" <[EMAIL PROTECTED]> writes: > | > Is it just me or others also think that it would be a major loss to > | > remove tkinter

Re: if __name__ == '__main__':

2008-03-20 Thread 7stud
On Mar 20, 10:21 am, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 4:12 PM, Bhagwat Kolde <[EMAIL PROTECTED]> wrote: > > Hi, > > I am new to the python and not getting meaning of following line, > > > if __name__ == '__main__': > >       main() > The if statement is used to

Re: is hash map data structure available in Python?

2008-03-19 Thread 7stud
On Mar 19, 2:40 am, grbgooglefan <[EMAIL PROTECTED]> wrote: > Hi, > I have a situation that I need to search a name in a big list of names > in my Python embedded interpreter. I am planning to use hash map for > quicker search. > How do I create hash map in Python? > Can you please guide me to some

Re: Need Help Starting Out

2008-03-18 Thread 7stud
On Mar 18, 10:10 am, jmDesktop <[EMAIL PROTECTED]> wrote: > Hi, I would like to start using Python, but am unsure where to begin. > I know how to look up a tutorial and learn the language, but not what > all technologies to use.   I think you are getting ahead of yourself. Get the book Learning P

Re: ord function problem from newbie

2008-03-17 Thread 7stud
[EMAIL PROTECTED] wrote: > I convert all to lowercase, > > import string > > small = string.lower(name) > print "Here is the calculated value:" > > print small > for ch in small: > v = ord(ch)-96 > print v > I don't know if you are using an

Re: Why does my compiler say invalid syntax then highlight...?

2008-03-10 Thread 7stud
On Mar 10, 9:44 pm, Nathan Pinno <[EMAIL PROTECTED]> wrote: > Why does my compiler say invalid syntax and then highlight the > quotation marks in the following code: > > # This program is to find primes. > primes = [] > import math > import gmpy > while 1: >     run = int(raw_input("Do you want to

Re: Why does my compiler say invalid syntax then highlight...?

2008-03-10 Thread 7stud
On Mar 10, 9:44 pm, Nathan Pinno <[EMAIL PROTECTED]> wrote: > Why does my compiler say invalid syntax and then highlight the > quotation marks in the following code: > > # This program is to find primes. > primes = [] > import math > import gmpy > while 1: >     run = int(raw_input("Do you want to

Re: tcp

2008-03-02 Thread 7stud
On Mar 2, 6:09 am, Gif <[EMAIL PROTECTED]> wrote: > i have this small script which after some router configurations works. > > ## > > #! /usr/bin/python > import socket > > HOST = '' > PORT = 1515 > s = socket.socket(socket.AF_INET, socket.SOC

Re: more pythonic

2008-02-28 Thread 7stud
On Feb 28, 4:48 am, 7stud <[EMAIL PROTECTED]> wrote: > > It's my understanding that the way you insert arguments into queries > has to be done in a db specific way.   > Rather: It's my understanding that the way you insert arguments into queries *should* be done in a

Re: more pythonic

2008-02-28 Thread 7stud
On Feb 28, 4:40 am, Temoto <[EMAIL PROTECTED]> wrote: > Hello. > > There is a Django application, i need to place all its data into > Access mdb file and send it to user. > It seems to me that params filling for statement could be expressed in > a more beautiful way. > Since i'm very new to Python,

Re: threading/Queue: join() and task_done() not working? (deadlock)

2008-02-28 Thread 7stud
On Feb 28, 1:47 am, Gal Aviel <[EMAIL PROTECTED]> wrote: > 7stud yahoo.com> writes: > > > What is task_done()?  The python docs don't list any such function. > > I'm using Python 2.5 and it's in the docs ... According to the docs, join() unblocks only

Re: call by reference howto????

2008-02-27 Thread 7stud
On Feb 27, 5:02 pm, Tamer Higazi <[EMAIL PROTECTED]> wrote: > Hi! > Can somebody of you make me a sample how to define a function based on > "call by reference" ??? > > I am a python newbie and I am not getting smart how to define functions, > that should modify the variable I passed by reference.

Re: threading/Queue: join() and task_done() not working? (deadlock)

2008-02-27 Thread 7stud
Gal Aviel wrote: > Hello All, > > I'm seeing strange behavior where one thread waits on a queue using join() and > the later (or so I think, according to order of the printing in STDOUT) > another > thread calls task_done() on the very same queue, What is task_done()? The python docs don't list

Re: BaseHTTPServer and do_POST method

2008-02-27 Thread 7stud
On Feb 27, 5:33 am, rocksportrocker <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to implement a local server for storing and retrieving > numerical data. > So I use BaseHTTPServer as follows: > > - >     from BaseHTTPServer import * > >  

Re: how to measure memory usage on Mac OSX ?

2008-02-26 Thread 7stud
On Feb 26, 3:43 am, "masayuki.takagi" <[EMAIL PROTECTED]> wrote: > hi all, > > i want to measure memory usage of my python process on Mac OSX. > > i tired resource module, but it doesn't work on OSX. > > how can i get it ? > > thnx. > > -- masayuki takagi #mac osx 10.4.7 import resource print res

Re: network programming: how does s.accept() work?

2008-02-26 Thread 7stud
On Feb 25, 10:00 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > >  7stud <[EMAIL PROTECTED]> wrote: > > But your claim that the server doesn't change its port flies in the > > face of every description I've read a

Re: network programming: how does s.accept() work?

2008-02-26 Thread 7stud
On Feb 25, 10:08 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > There can be many TCP connections to a server all using the same > endpoint. Take a look at the traffic coming out of any busy web server: > everything that comes out of the same server comes from port 80. That > doesn't stop it listeni

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: > 7stud <[EMAIL PROTECTED]> wrote: > > The question I'm really trying to answer is: if a client connects to a > > host at a specific port, but the server changes the port when it > > creates a n

Re: Is there any method to urlretrieve to a file the html source from a url with "Transfer-encoding": chunked

2008-02-25 Thread 7stud
On Feb 25, 8:25 am, Aldo Ceccarelli <[EMAIL PROTECTED]> wrote: > Thank you All for your suggestions: > > I could finally assess that > > besides partial read from chunked url - by-passed thanks to a socket > approach: > > f.i. this was good for > me:http://python.about.com/od/networkingwithpython/

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 5:17 am, 7stud <[EMAIL PROTECTED]> wrote: > On Feb 25, 4:08 am, 7stud <[EMAIL PROTECTED]> wrote: > > > > > The question I'm really trying to answer is: if a client connects to a > > host at a specific port, but the server changes the port whe

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 4:08 am, 7stud <[EMAIL PROTECTED]> wrote: > > The question I'm really trying to answer is: if a client connects to a > host at a specific port, but the server changes the port when it > creates a new socket with accept(), how does data sent by the client >

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 2:43 am, [EMAIL PROTECTED] wrote: > > by reusing the same variables without storing the previous values. > This could make the Python > garbage collector to attempt freeing the socket object created with > the first connection, therefore > closing the connection. > > If I'm right, your p

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 2:43 am, [EMAIL PROTECTED] wrote: > On 25 Feb, 09:51, 7stud <[EMAIL PROTECTED]> wrote: > > > > > I have the following two identical clients > > > #test1.py:--- > > import socket > > > s = socket.socket(socket.AF_INET, socket.SOCK_

network programming: how does s.accept() work?

2008-02-25 Thread 7stud
I have the following two identical clients #test1.py:--- import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = 'localhost' port = 5052 #server port s.connect((host, port)) print s.getsockname() response = [] while 1: piece = s.recv(1024) if piece == '':

Re: Create multiple directories

2008-02-24 Thread 7stud
On Feb 24, 6:27 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Paul Lemelle wrote: > > I am somewhat new to Python and I am trying to create a program that > > automatically creates directories from a range of numbers. I > > researched the os.mkdir & os.makedirs methods, but they do not seem to > > (

Re: n00b with urllib2: How to make it handle cookie automatically?

2008-02-24 Thread 7stud
On Feb 24, 4:41 am, est <[EMAIL PROTECTED]> wrote: > On Feb 23, 2:42 am, Rob Wolfe <[EMAIL PROTECTED]> wrote: > > > > > est <[EMAIL PROTECTED]> writes: > > > Hi all, > > > > I need urllib2 do perform series of HTTP requests with cookie from > > > PREVIOUS request(like our browsers usually do ). Man

  1   2   3   4   5   6   >