federico ramirez wrote: > well, im very angry :( > I cant get this to work > > When i try this it works > > #!/usr/bin/python > > import Cookie > C = Cookie.SimpleCookie() > C['adminuser'] = 'fedekiller' > C['adminuser']['max-age'] = 60*60*24*7 > print C > print "Content-Type: text/html\n\n" > print "Bienvenido",C['adminuser'].value,'!' > Here you're defining a SimpleCookie object called 'C' then you're adding attributes to it. Later, when you print it, you're referencing the 'C' object. For example, when the python interpreter sees C['adminuser'] It says C -> instance of class SimpleCookie. instance.__getitem__('adminuser') returns 'fedekiller' #(this is the method of a class that's called whenever you attempt to #reference it as a dictionary.)
> > but when i try this it doesnt > > #!/usr/bin/python > > import Cookie > print "Content-Type: text/html\n\n" > print "Bienvenido",C['adminuser'].value,'!' > Now here, the python interpreter says C -> ??? and it raises an exception, telling you that C is not defined. You never declared what 'C' was, so you can't expect python to read your mind ;) > I dont know why... i know the cookie exists because firefox display it > where all the cookies of that domains are. > So, i need help with this please :( In the future, if you include the traceback, instead of just saying 'it doesn't work,' you're _much_ more likely to get a helpful response. Otherwise you might just get 'need more info.' and the time until you get a useful reply will be longer because you'll have to write another e-mail to the list. Also, if you only have to send one e-mail before you get the reply you need, the traffic on the list is much smaller. In this particular example, it was easy to see what the problem was without running the code, but if someone has to run your code and debug it themselves they ( I ) won't enjoy doing this and won't actually help you. If you don't include tracebacks and such, it seems like you haven't attempted to debug it yourself. The tutor list is here to help you with problems that you have no idea how to solve, and you have to tell us what steps you took to _try_ to solve it, so we can tell you what the next step is. If we just give you answers to your questions, you won't have learned anything, right? :) > I know im a noob sorry U-U That's what the list is here for! But we also want to help you get un-newbied as fast as possible :) > > -- > Best Regards. > fedekiller -Luke _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor