Re: which datastructure for fast sorted insert?

2008-05-25 Thread notnorwegian
Traceback (most recent call last): File "C:/Python25/Progs/WebCrawler/spider2.py", line 47, in x = scrapeSites("http://www.yahoo.com";) File "C:/Python25/Progs/WebCrawler/spider2.py", line 31, in scrapeSites site = iterator.next() RuntimeError: Set changed size during iteration def j

Re: which datastructure for fast sorted insert?

2008-05-25 Thread notnorwegian
On 26 Maj, 03:04, [EMAIL PROTECTED] wrote: > On 26 Maj, 01:30, I V <[EMAIL PROTECTED]> wrote: > > > > > On Sun, 25 May 2008 15:49:16 -0700, notnorwegian wrote: > > > i meant like set[pos], not iterate but access a specific position in the > > > set. >

Re: which datastructure for fast sorted insert?

2008-05-25 Thread notnorwegian
On 26 Maj, 01:30, I V <[EMAIL PROTECTED]> wrote: > On Sun, 25 May 2008 15:49:16 -0700, notnorwegian wrote: > > i meant like set[pos], not iterate but access a specific position in the > > set. > > If you need to access arbitrary elements, use a list instead of a s

Re: which datastructure for fast sorted insert?

2008-05-25 Thread notnorwegian
On May 25, 9:32 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 25 May 2008 00:10:45 -0700, notnorwegian wrote: > > sets dont seem to be so good because there is no way to iterate them. > > Err: > > In [82]: for x in set(['a', '

22.800000 and a 1 on the end!!??

2008-05-25 Thread notnorwegian
>>> x = 5 >>> x /= 2 >>> x 2 >>> x *=11.4 >>> x 22.801 ok where does the 1 in the come from? -- http://mail.python.org/mailman/listinfo/python-list

Re: which datastructure for fast sorted insert?

2008-05-25 Thread notnorwegian
On 25 Maj, 08:56, Rares Vernica <[EMAIL PROTECTED]> wrote: > use a set to store them: > > >>> s=set() > >>> s.add('a') > >>> s.add('b') > >>> s > set(['a', 'b']) > >>> s.add('a') > >>> s > set(['a', 'b']) > >>> s.add('c') > >>> s > > set(['a', 'c', 'b']) > > > > it does remove duplicates, but is it

recursion with or without return?

2008-05-25 Thread notnorwegian
when using recursion should one use a return statement or not? there is a difference obv since with a return statement it will ultimately return a value if not recursing forever. but is there a guideline for this or it just taste or is it considering good style or pythonic to always have a return

which datastructure for fast sorted insert?

2008-05-24 Thread notnorwegian
im writing a webcrawler. after visiting a new site i want to store it in alphabetical order. so obv i want fast insert. i want to delete duplicates too. which datastructure is best for this? -- http://mail.python.org/mailman/listinfo/python-list

class-oriented rather than object-oriented?

2008-05-24 Thread notnorwegian
i have some confusion over this. sure a class is basically a classification, like for example an animal or flower. and an object/instance of that class is then for example a cat. an object is an instance of a class. that i know, i also know how to program with classes etc. i am just confused abo

webspider getting stuck

2008-05-24 Thread notnorwegian
i am writing a simple webspider . how do i avoid getting stuck at something like this: Enter username for W3CACL at www.w3.org: ? i can obv add an if-clause for the specific site but since i guess there will be more of the same thats ov not a viable approach in the long run. -- http://mail.pytho

Re: why is com-prompt faster and how do i start at cprompt at mydir/ ?

2008-05-23 Thread notnorwegian
On 24 Maj, 07:01, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > On 24 Maj, 05:48, Ben Finney <[EMAIL PROTECTED]> > > wrote: > > > Can you tell us exactly which programs you mean when you say "the > > > shell" and "the commandprompt"? > > > commandprompt = windows dos-windows

Re: why is com-prompt faster and how do i start at cprompt at mydir/ ?

2008-05-23 Thread notnorwegian
On 24 Maj, 05:48, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > when running a very computationalheavy program in the shell it > > sometimes freezes but the commandprompt runs it without problems > > Can you tell us exactly which programs you mean when you say "the > shell"

why is com-prompt faster and how do i start at cprompt at mydir/ ?

2008-05-23 Thread notnorwegian
when running a very computationalheavy program in the shell it sometimes freezes but the commandprompt runs it without problems and muh faster, why? also, the command prompt starts at C:\Users\user> i want to start at C:\python25\progs how do i change that? -- http://mail.python.org/mailman/lis

simple url regexp

2008-05-23 Thread notnorwegian
url = re.compile(r"((http|ftp|https)\:\/\/)(www)?([a-zA-Z]{1}([\w\-]+ \.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+ \.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?") damn i hate these things. i want it to only match http://www.name.any/etc not http://wiki.x etc -- http://mail.python.org/mailman/listi

webspider, regexp not working, why?

2008-05-23 Thread notnorwegian
url = re.compile(r"^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z] {1} ([\w\-]+\.)+ ([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)? (& \w+=\w+)*)?") why isnt this url catching something like: http://www.showmedo.com/latestVideoFeed/rss2.0? tag=python" /> site = urllib.url

Re: spider, why isnt it finding the url?

2008-05-22 Thread notnorwegian
On 23 Maj, 02:02, [EMAIL PROTECTED] wrote: > this program doesnt produce any output, however i know from testing > that the url-regexp matches urls... > > import urllib > import re > > site = urllib.urlopen("http://www.python.org";) > > email = re.compile(r'[EMAIL PROTECTED],4}') > url = re.compile

spider, why isnt it finding the url?

2008-05-22 Thread notnorwegian
this program doesnt produce any output, however i know from testing that the url-regexp matches urls... import urllib import re site = urllib.urlopen("http://www.python.org";) email = re.compile(r'[EMAIL PROTECTED],4}') url = re.compile("^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1} ([\w\

serach file for regexp, return if found?

2008-05-22 Thread notnorwegian
i want to search a document for a particular regexp and then store that regexp to a file. but search and match only returns matchobjects(what are those anyway? i dont get what to do with them, do they contain true/false, stringposition etc?) how do i do: for rows in file: print regexp.find #

import X vs from x import *

2008-05-22 Thread notnorwegian
import Tkinter from Tkinter import * i have a program where if i comment out either of those import- statements i get an error. i thought they meant the same thing and from was supposed to be just to imort just a specific function and the * imports everything in the module. but aparently the abov

Psyche (scheme in python), how to run on vista?

2008-05-21 Thread notnorwegian
anyone using psyche? how do you run it on Vista? what file do you click? there is no obvious file like psyche.py... -- http://mail.python.org/mailman/listinfo/python-list

self.var hmm?

2008-05-20 Thread notnorwegian
class TaskGroup: def __init__(self): self.group = [] def addTask(self, task): self.group.append(task) is this wrong? i have a program thats too big to post but should i just do group.append in addTask? reason is when later doing TaskGroup.group i get None -- http://mail

iterate start at second row in file not first

2008-05-20 Thread notnorwegian
i have a big file with sentences, the first file of each sentence contains a colon(:) somewher eon that line i want to jump past that sentence. if all(x != ':' for x in line): this way i can check but i dont want to check for every line in the whole file, quite unnecessary when i only need to ch

test mult vars to same value, how to shorten expr?

2008-05-19 Thread notnorwegian
if i want o test: if a == 5 and b ==5 and c==5 ... z==5 is there some synctactic suagr for this? rather than maiking one of my own i mean, something built-in like: if a,b,c... z == 5: -- http://mail.python.org/mailman/listinfo/python-list

Re: conventions/requirements for 'is' vs '==', 'not vs '!=', etc

2008-05-19 Thread notnorwegian
i am confused. x=5 y=5 x==y -> True x is y -> True shouldnt x is y return False since they shouldnt(dont?) point to the same place in memory, they just store an equal value? -- http://mail.python.org/mailman/listinfo/python-list

this worked before...' '.join([`x x` for x in range(1, 6)])

2008-05-19 Thread notnorwegian
' '.join([`x x` for x in range(1, 6)]) anyone can tell me what im doing wrong? -- http://mail.python.org/mailman/listinfo/python-list