Re: [Tutor] python coding problem

2016-09-26 Thread Alex Hall
t are > confidential and intended solely for the use of the individual or entity to > whom they are addressed. If you have received this email in error please > notify the sender. > ___ > Tutor maillist - Tuto

Re: [Tutor] decorators -- treat me like i'm 6.. what are they.. why are they?

2016-07-06 Thread Alex Hall
On Wed, Jul 6, 2016 at 4:56 PM, Alex Hall wrote: > > > On Wed, Jul 6, 2016 at 3:35 PM, bruce wrote: > >> Hi. >> >> Saw the decorator thread earlier.. didn't want to pollute it. I know, I >> could google! >> >> But, what are decorators, why

Re: [Tutor] decorators -- treat me like i'm 6.. what are they.. why are they?

2016-07-06 Thread Alex Hall
> Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ T

Re: [Tutor] Subclassing logging.Handler?

2016-07-06 Thread Alex Hall
On Wed, Jul 6, 2016 at 1:01 PM, Alex Hall wrote: > Regarding this project: I've gone ahead and tried a variant of it. I > wanted to log to an HTML file, since those are much easier to look at with > a screen reader and so I could get used to the concepts involved. Here's >

Re: [Tutor] Subclassing logging.Handler?

2016-07-06 Thread Alex Hall
se(self): self.stream.write(""" """) super(ADTimedRotatingLogFileHandler, self).close() On Wed, Jul 6, 2016 at 8:32 AM, Alex Hall wrote: > Hey list, > Another day, another Python experiment. I'm wondering what methods I'd > have t

[Tutor] Subclassing logging.Handler?

2016-07-06 Thread Alex Hall
ve to worry about? To be clear, I'm not asking about logging to a database, only what to do to make a Handler subclass capable of logging through whatever mechanisms I want. Thanks. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com

Re: [Tutor] isinstance versus 'is'?

2016-07-06 Thread Alex Hall
asking if the value is the literal None object. It seems it's the way None is handled, not an exception in the way 'is' works. Anyway, thanks for the explanations. > On Jul 5, 2016, at 20:54, Steven D'Aprano wrote: > > On Tue, Jul 05, 2016 at 03:05:45PM -0400, Alex Hall

[Tutor] isinstance versus 'is'?

2016-07-05 Thread Alex Hall
t;> a is int False What happened there? Don't these do the same thing? I thought I could use them interchangeably? -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ Tutor maillist - Tutor@python.org To unsubscribe or ch

Re: [Tutor] Writing decorators?

2016-07-05 Thread Alex Hall
e empty, given that anywhere else doing so would return the function object rather than call it. Yet, if arguments are passed, you include them like you would anywhere else. Or am I misunderstanding it? > > Sent from my Fonepad > > Alex Hall wrote: > > Okay, I think I follow. So a decor

[Tutor] Writing decorators?

2016-07-05 Thread Alex Hall
r and helpful? Thanks for any links and/or explanations. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] iterators

2016-07-04 Thread Alex Hall
I believe the problem is what the error says: you're passing an int. When you give it two values, you're giving it a tuple, like (1, 2). That's a list type object in Python, and the 'in' keyword has to operate on lists. Therefore, it works. When you give it one value, though, you're giving it a

[Tutor] For-else... Any other handy constructs hiding in Python?

2016-06-24 Thread Alex Hall
statements like this? Python has a lot of really cool shortcuts and features, like get/hasattr, the yield keyword, or comprehensions. I always like finding more to add to the toolbox. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com

Re: [Tutor] Best way to use excepthook here?

2016-06-24 Thread Alex Hall
bs I need tries to transform, say, non-existent dictionary values into 0 or some other constant. On Fri, Jun 24, 2016 at 12:28 AM, Peter Otten <__pete...@web.de> wrote: > Alex Hall wrote: > > > Hey all, > > How would I go about sharing a reassignment of excepthook, w

[Tutor] Best way to use excepthook here?

2016-06-23 Thread Alex Hall
hing to make sure each job logs exceptions, and does it correctly, no matter who else is running at the same time? Thanks. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Urgent: unicode problems writing CSV file

2016-06-08 Thread Alex Hall
Thanks for all the responses, everyone, what you all said makes sense. I also understand what you mean by the tone of an "urgent" message coming across as demanding. On Wed, Jun 8, 2016 at 1:19 PM, Tim Golden wrote: > On 08/06/2016 14:54, Alex Hall wrote: > > All, > >

Re: [Tutor] Urgent: unicode problems writing CSV file

2016-06-08 Thread Alex Hall
ully sure why or how. csvWriter.writerow([info.encode("utf8") if type(info)is unicode else info for info in resultInfo]) where resultInfo is an array holding the values from a row of database query results, in the order I want them in. On Wed, Jun 8, 2016 at 1:08 PM, Peter Otten <__pete...@

[Tutor] Urgent: unicode problems writing CSV file

2016-06-08 Thread Alex Hall
I've tried str(info).encode("utf8") str(info).decode(utf8") unicode(info, "utf8") csvFile = open("myFile.csv", "wb", encoding="utf-8") #invalid keyword argument What else can I do? As I said, I really have to get this working soon, but I&

Re: [Tutor] Practice Exercises for Beginner ?

2016-06-03 Thread Alex Hall
Make something. :) I know it's pretty open-ended, but just think of an application you want to make, and try to make it in Python. Stick to command line at first, but then try WX or another GUI library. The more times you get stuck, the more you learn and the more you'll know for next time. Make

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Alex Hall
n the attached screenshot > [image: Inline image 2] > > whereas I want only one list containing strings not nested lists. > > Any help would be appreciated. > > *Warm regards,* > > *Olaoluwa O. Thomas,* > *+2347068392705* > ___

Re: [Tutor] OrderedDict?

2016-06-02 Thread Alex Hall
Thanks. I've never used that module before, and didn't realize it's not imported by default, which must be why my first tries failed. I've got it working now. > On Jun 1, 2016, at 18:45, Alan Gauld via Tutor wrote: > > On 01/06/16 16:36, Alex Hall wrote:

[Tutor] OrderedDict?

2016-06-01 Thread Alex Hall
plus some home-grown suggestions on how to implement this, but so far that's it. Although I thought this was in 2.7, it doesn't appear on the Data Structures page at all. What am I missing? Thanks. -- Alex Hall Automatic Distributors, IT

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
, so wanted to check that those are indeed the recommended ways. On Wed, May 25, 2016 at 3:37 PM, Alan Gauld via Tutor wrote: > On 25/05/16 19:11, Alex Hall wrote: > > > As a quick aside, is there an easy way to halt script execution for some > > exceptions? Right now, catchi

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
n Wed, May 25, 2016 at 2:11 PM, Alex Hall wrote: > Hello again list, > I didn't expect to be back so soon. :) I'm trying to log my new script, > and logger.info() works fine. However, logger.exception() doesn't; I see > the exception print to stderr, and it never appea

[Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
ution continues, but I sometimes want to log the problem and then abort the script, as the error means it shouldn't continue. Thanks. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ Tutor maillist - Tutor@python.or

[Tutor] Baffling problem with a list of objects sharing a property

2016-05-25 Thread Alex Hall
for i in range(len(tests)): print tests[i] tests[i].paths.append("a") print tests[i] If anyone can explain what's happening, I'd very much appreciate it. I'm on Windows 7, Python 2.7.11. Thanks. -- Alex Hall Automatic Distributors, IT department ah...@autodist.

Re: [Tutor] working with c_byte?

2012-03-23 Thread Alex Hall
1:51 PM, Alex Hall wrote: >> Hi all, >> I am trying to read battery information. I found an example that sets >> up a ctypes structure to get the information from a kernel call, and >> it works... except that I just realized the values of some fields are >> added. For

[Tutor] working with c_byte?

2012-03-23 Thread Alex Hall
Hi all, I am trying to read battery information. I found an example that sets up a ctypes structure to get the information from a kernel call, and it works... except that I just realized the values of some fields are added. For instance, a value of 1 means that the battery is "high", and 8 means it

Re: [Tutor] Simple Question (I Hope)

2012-01-14 Thread Alex Hall
On 1/14/12, Chris Kavanagh wrote: > I was looking at this code from the Python Docs > (http://docs.python.org/library/email-examples.html), trying to learn > how to send email from a Pyhton script. Anyways, part of this code > confused me. Here's the script: > > 1 # Import smtplib for the actual s

Re: [Tutor] making a custom file parser?

2012-01-07 Thread Alex Hall
f there's no tree structure, or its only one level deep, using > ElementTree is probably overkill and just gives you lots of leaking > abstractions to plug for little benefit. Why not just scan the file > directly? > > Cheers > > On Saturday 07 January 2012, Alex Hall wrote: >

[Tutor] making a custom file parser?

2012-01-07 Thread Alex Hall
Hello all, I have a file with xml-ish code in it, the definitions for units in a real-time strategy game. I say xml-ish because the tags are like xml, but no quotes are used and most tags do not have to end. Also, comments in this file are prefaced by an apostrophe, and there is no multi-line comme

Re: [Tutor] list.index() question

2011-12-08 Thread Alex Hall
On 12/8/11, Robert Berman wrote: > Hi, > > Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want > to get the index of 'c'. A one dimensional list is extremely easy; val = > list.index(value). But how do I get it for a list similar to l1. I have > tried ind = l1[0].index('c') an

Re: [Tutor] urgent help!!!!!!!!!!!

2011-11-17 Thread Alex Hall
My mail client stripped new lines, at least on this machine, so I will just top-post this. Sorry! Your problem is that you say: amount=0 def main()... You then try to use amount in main, but main has no amount in it. Either move "amount=0" inside main, or put a global reference: amount=0 def main()

Re: [Tutor] Find all strings that....

2011-11-10 Thread Alex Hall
What about just grabbing a bit text file, such as from Project Gutenberg (sorry for the possibly incorrect spelling)? Or copying the text from a large webpage and pasting it into a text file? On 11/10/11, Alexander Etter wrote: > > > Hi. My friend gave me a good wake up exercise which I do not wa

Re: [Tutor] assign all parameters of __init__ to class variables?

2011-11-04 Thread Alex Hall
No, I mean what you said. My class has one or two class-level: class myClass: x=5 and a lot of instance-level: def __init__(self, p1, p2...): self.__dict__.update(locals()) On 11/4/11, Steven D'Aprano wrote: > Alex Hall wrote: >> I'm sorry, I misspoke (well, mistype

Re: [Tutor] assign all parameters of __init__ to class variables?

2011-11-02 Thread Alex Hall
I'm sorry, I misspoke (well, mistyped anyway). I have a couple class-level variables, but most of them are set in the __init__ so that every instance gets a fresh copy of them. Thatnks for the responses. On 11/2/11, Steven D'Aprano wrote: > On Thu, 3 Nov 2011 12:57:25 am Al

Re: [Tutor] assign all parameters of __init__ to class variables?

2011-11-02 Thread Alex Hall
ot; twenty times seems like a waste of time and space. On 11/2/11, Christian Witts wrote: > On 2011/11/02 03:15 PM, Alex Hall wrote: >> Hi all, >> I have a class which takes a large number of optional arguments for >> its __init__. Instead of going through every single one and

[Tutor] assign all parameters of __init__ to class variables?

2011-11-02 Thread Alex Hall
Hi all, I have a class which takes a large number of optional arguments for its __init__. Instead of going through every single one and assigning it to "self.[name]", is there some quick way to take all the parameters of the constructor and assign them all to self.[name] in one step? -- Have a gr

Re: [Tutor] difference between super() and parent.__init__()?

2011-10-21 Thread Alex Hall
On 10/21/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hi all, >> I am just curious: I have seen classes that are subclasses initialize >> their parents through both super and parentClass.__init__. What is the >> difference, if any, and is one "better&

[Tutor] difference between super() and parent.__init__()?

2011-10-21 Thread Alex Hall
Hi all, I am just curious: I have seen classes that are subclasses initialize their parents through both super and parentClass.__init__. What is the difference, if any, and is one "better" or "more pythonic" than the other? -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com

Re: [Tutor] logging question

2011-10-20 Thread Alex Hall
Thanks, raise should do it. I read later on last night that raise called with nothing else re-raises the last exception, but never thought of using it in my situation. On 10/20/11, Christian Witts wrote: > On 2011/10/19 09:19 PM, Alex Hall wrote: >> Hi all, >> I have never done

[Tutor] logging question

2011-10-19 Thread Alex Hall
Hi all, I have never done logging before, and I am wondering how it will change my script. Currently, I have something like this: for book in results: try: checkForErrors(book) except Exception, e: print e continue That way I see any errors in a given book, but that book is skipped and the l

Re: [Tutor] Help!

2011-10-07 Thread Alex Hall
On 10/7/11, rmntcver...@aol.com wrote: > I need serious help with this Rock, Paper, Scissors program. The program > runs smoothly but I can't get the score to print. Please help me with this > one aspect! Here is my code right now: > > > > import random > > > def computerrockPaperScissors(): >

Re: [Tutor] force imports from site-packages?

2011-10-06 Thread Alex Hall
Thanks, it is now working properly. It turned out to be something in the __all__ list that didn'tmake much sense, but now that I know what to use it is working. On 10/6/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hi all, >> I have managed to get a couple of packag

[Tutor] force imports from site-packages?

2011-10-06 Thread Alex Hall
Hi all, I have managed to get a couple of packages in site-packages which share names with some folders in the same directory as a program, or at least a subdir somewhere below has the same name. Is there a way to force my script to look in lib/site-packages before the script's folder? I can't rena

Re: [Tutor] Python Speech

2011-08-23 Thread Alex Hall
Sorry, the link is: http://hg.qwitter-client.net then select "accessible output". On 8/23/11, Christopher King wrote: > Sorry, forgot to hit reply all. > -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _

Re: [Tutor] Python Speech

2011-08-23 Thread Alex Hall
Depending on what you want, you could try accessible_output. This uses the first available screen reader to speak, or sapi5 speech if no screen reader is loaded. I believe the link is: http://hg.qwitter-client.net/dependencies HTH. On 8/23/11, Steven D'Aprano wrote: > Christopher King wrote: >> H

Re: [Tutor] using configobj package to output quoted strings

2011-06-18 Thread Alex Hall
On 6/18/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hello all, >> I am using the configobj package to handle a ridiculously simple ini > > What's configobj? > > >>> import configobj > Traceback (most recent call last): >File &quo

[Tutor] using configobj package to output quoted strings

2011-06-18 Thread Alex Hall
Hello all, I am using the configobj package to handle a ridiculously simple ini file, which takes the form: [favorites] "search name" = "search terms", "search type" for any number of searches stored in the favorites section. I need the search type, term, and name to be read in as strings, but the

Re: [Tutor] Help with understanding classes

2011-05-21 Thread Alex Hall
On 5/21/11, Robert Sjöblom wrote: > I'm trying to wrap my head around classes and their attributes, but am > having a hard time doing so. The websites and books that I have consulted > haven't been much help; most of them assume prior programming/oop > experience, something I lack. > > From what I

Re: [Tutor] a function I fail to understand

2011-03-21 Thread Alex Hall
On 3/21/11, David wrote: > Hello list, > > I am having trouble understanding the following function. What trips me > up is the "letter = letter.lower()" line. > > As I understand, the function takes a letter and assigns True to a > letter if it is upper case. No, the function takes a letter and re

[Tutor] very odd math problem

2011-03-10 Thread Alex Hall
Hi all, I am trying to get a list of ordered pairs from the below function. In my code, evaluate is more exciting, but the evaluate here will at least let this run. The below runs fine, with one exception: somehow, it is saying that -2+2.0 is 4.x, where x is a huge decimal involving E-16 (in other

Re: [Tutor] Unintentionally manipulating a list

2011-02-25 Thread Alex Hall
You may want to deepcopy instead of just copy? On 2/25/11, ranjan das wrote: > I am facing the following problem > > > I have a list of the form > > INPUT= [ [ ['A1-N','A2-Y','A3-N' ],['B1-Y','B2-N','B3-N' ] ], [.] ] > > > and I want an output of the form (selecting only those elements wh

Re: [Tutor] Display all field of a listuples

2011-02-24 Thread Alex Hall
this* : > > Froid devorant : Gele lenemi sur place > Flammes infernales : Embrase lenemi et le feu bruler > > I don't know how to get this ? :( Again, what is the error (traceback) you get when you try to run the code? > > 2011/2/24 Steven D'Aprano > >> Alex Ha

Re: [Tutor] Display all field of a listuples

2011-02-24 Thread Alex Hall
this* : > > Froid devorant : Gele lenemi sur place > Flammes infernales : Embrase lenemi et le feu bruler > > I don't know how to get this ? :( Again, what is the error (traceback) you get when you try to run the code? > > 2011/2/24 Steven D'Aprano > >> Alex Ha

Re: [Tutor] Display all field of a listuples

2011-02-24 Thread Alex Hall
On 2/24/11, Christopher Brookes wrote: > Hi i would like to display all the field of my powerAll like this : > > Choose a power : > Froid devorant : Embrase lenemi et le feu bruler > Flammes infernales : 'Gele lenemi sur place > > - > class Character(): > def Choose

Re: [Tutor] relative imports

2011-02-24 Thread Alex Hall
Sorry, I forgot to say that the error is: ValueError: attempted relative import in non-package. On 2/24/11, Alex Hall wrote: > Hi all, > I am trying to place some common files into a folder so that all files > in other folders can access the common files. That is, the file for a > c

Re: [Tutor] licensing python work?

2011-02-23 Thread Alex Hall
Thanks, everyone, for the feedback. I went with the suggestion of adding my name to it, mentioning that I am not responsible for anything that happens, a request for credit somewhere in an application that uses the wrapper (though not a requirement), and that's pretty much it. I think this thing ha

[Tutor] licensing python work?

2011-02-23 Thread Alex Hall
Hi all, This is not strictly on topic and probably has a very obvious answer, but I want to make sure I do it right. How do I license something I write? I have that Bookshare wrapper done, at least as far as I can tell, and I want to give it to Bookshare so they can provide it to whomever wants it.

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, bob gailer wrote: > On 2/5/2011 2:46 PM, Alex Hall wrote: >> Hi all, >> I have a class which has a list as an attribute, meaning you must say >> something like: >> for result in obj.results: ... >> I want to make life a bit easier and let use

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, Siim Märtmaa wrote: > 2011/2/5 Alex Hall : >> Yes, I get the same thing. However, when you try to index, as in a[0], >> you have problems. Here are two lines from my program: >> for i in res: print i >> This works as expected, printing every object in res.r

Re: [Tutor] making object iterable

2011-02-05 Thread Alex Hall
On 2/5/11, Peter Otten <__pete...@web.de> wrote: > Alex Hall wrote: > >> Hi all, >> I have a class which has a list as an attribute, meaning you must say >> something like: >> for result in obj.results: ... >> I want to make life a bit easier an

[Tutor] making object iterable

2011-02-05 Thread Alex Hall
Hi all, I have a class which has a list as an attribute, meaning you must say something like: for result in obj.results: ... I want to make life a bit easier and let users just say: for result in obj: ... Here is what I have tried to make my class into an iterable one, yet I get an error saying tha

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
ly possible in Python to set methods to return 'self' > if/when that would be useful, but if it is not a language level feature, it > becomes a convention that one can only rely on in ones own code. > > regards, > Bill > > On Feb 4, 2011, at 11:56 AM, Alex Hall wro

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
On 2/4/11, Bill Felton wrote: > Um, yes, emphatically yes. You missed the context, which was Smalltalk, and > it is terms of Smalltalk that my reply is couched. > Yes, Python returns None. > Smalltalk returns self by default. > Given the dropped context, you are correct. > Given the context meant

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-04 Thread Alex Hall
On 2/4/11, Alan Gauld wrote: > "Alex Hall" wrote > >> I am wondering what the best way to do the following would be: throw >> an exception, or always return an object but set an error flag if >> something goes wrong? Here is an example: > > Throw an ex

Re: [Tutor] best practice: throw exception or set a flag?

2011-02-03 Thread Alex Hall
soul stolen by angry programmers and doomed to working on Windows, let alone kernel debugging... :) Now, if it were Android, there might be something to the idea. On 2/3/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hi all, >> I am wondering what the best way to do the follow

[Tutor] best practice: throw exception or set a flag?

2011-02-03 Thread Alex Hall
Hi all, I am wondering what the best way to do the following would be: throw an exception, or always return an object but set an error flag if something goes wrong? Here is an example: class c: def __init__(self): self.error=False def func(self, val): if val!=10: self.error=True someObj=c()

Re: [Tutor] noobie question,,,error related

2011-01-30 Thread Alex Hall
On 1/30/11, walter weston wrote: > I get this error when I try and load the datetime module, > > Traceback (most recent call last): > File "C:/Python27/TIMED_PROGRAM.py", line 2, in > datetime.ctime() > AttributeError: 'module' object has no attribute 'ctime' > > > why is this? Did you actu

Re: [Tutor] getting binary file from website with custom header

2011-01-29 Thread Alex Hall
On 1/29/11, Steven D'Aprano wrote: > Alex Hall wrote: > >> Sorry. http://api.bookshare.org. > > Hmmm, I get: > > 403 Developer Inactive > > so that's no help to me. However, I did find this: > > http://developer.bookshare.org/docs/Home/ > > [

Re: [Tutor] getting binary file from website with custom header

2011-01-28 Thread Alex Hall
On 1/29/11, Steven D'Aprano wrote: > A few more comments... > > Alex Hall wrote: >> Hello, >> I am continuing to work on that api wrapper... I never realized how >> little I know about urllib/urllib2! The idea of downloading from the >> api is pretty eas

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Alex Hall, 28.01.2011 14:25: >> On 1/28/11, Stefan Behnel wrote: >>> Alex Hall, 28.01.2011 14:09: >>>> On 1/28/11, Stefan Behnel wrote: >>>>> Alex Hall, 27.01.2011 23:23: >>>>>> self

[Tutor] getting binary file from website with custom header

2011-01-28 Thread Alex Hall
Hello, I am continuing to work on that api wrapper... I never realized how little I know about urllib/urllib2! The idea of downloading from the api is pretty easy: give it a url and a password and it gives you the book. Here is a quote from the api documentation: In addition the MD5 hash of the end

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/28/2011 08:02 AM, Alex Hall wrote: >> On 1/28/11, Dave Angel wrote: >>> On 01/-10/-28163 02:59 PM, Alex Hall wrote: >>>> >>>> I tried both of those and got a different error. I have since fixed it >>&

Re: [Tutor] What does ^ and | mean?

2011-01-28 Thread Alex Hall
Not sure about caret (^), but I believe | is binary or. 4|2 is 100 | 010 = 110, and 110 in decimal is 6. 4|4= 100|100 is 100 or 4. The caret might be binary and, but I am not sure. On 1/28/11, tee chwee liong wrote: > > hi, > > i'm confuse on how does ^ and | mean. When i tried |, i thought it i

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Alex Hall, 28.01.2011 14:09: >> On 1/28/11, Stefan Behnel wrote: >>> Alex Hall, 27.01.2011 23:23: >>>>self.id=root.find("id").text >>>> self.name=root.find("name).text >>> >>> Ther

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Alex Hall
On 1/28/11, Stefan Behnel wrote: > Hi, > > since you said that you have it working already, here are just a few > comments on your code. > > Alex Hall, 27.01.2011 23:23: >> all=root.findall("list/result") >> for i in all: >> self.mylist.append(Ob

Re: [Tutor] ascii codec cannot encode character

2011-01-28 Thread Alex Hall
On 1/28/11, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Alex Hall wrote: >> >> I tried both of those and got a different error. I have since fixed it >> so I no longer have the exact text, but it was something about not >> supporting convertion from unicode. I

Re: [Tutor] ascii codec cannot encode character

2011-01-27 Thread Alex Hall
On 1/27/11, Steven D'Aprano wrote: > Alex Hall wrote: >> Hello again: >> I have never seen this message before. I am pulling xml from a site's >> api and printing it, testing the wrapper I am writing for the api. I >> have never seen this error until

Re: [Tutor] small ElementTree problem

2011-01-27 Thread Alex Hall
= zip(ids, names) > * > > You are not obliged to provide the full XPATH. Etree search for you. > > Regards > Karim > > On 01/27/2011 11:23 PM, Alex Hall wrote: >> Hi all, >> I am using, and very much enjoying, the ElementTree library. However, >>

[Tutor] ascii codec cannot encode character

2011-01-27 Thread Alex Hall
Hello again: I have never seen this message before. I am pulling xml from a site's api and printing it, testing the wrapper I am writing for the api. I have never seen this error until just now, in the twelfth result of my search: UnicodeEncodeError: 'ASCII' codec can't encode character u'\u2019' i

[Tutor] small ElementTree problem

2011-01-27 Thread Alex Hall
Hi all, I am using, and very much enjoying, the ElementTree library. However, I have hit a problem. Say I have something along the lines of: Message from Service 1.0 1 result 1 2 result 2 In my ResultSet class, I parse this to get the text of elements like message or

Re: [Tutor] get xml for parsing?

2011-01-27 Thread Alex Hall
On 1/27/11, Stefan Behnel wrote: > Alex Hall, 27.01.2011 05:01: >> How would I go about getting the xml from a website through the site's >> api? The url does not end in .xml since the xml is generated based on >> the parameters in the url. For example: >> https://

[Tutor] get xml for parsing?

2011-01-26 Thread Alex Hall
Hi all, How would I go about getting the xml from a website through the site's api? The url does not end in .xml since the xml is generated based on the parameters in the url. For example: https://api.website.com/user/me/count/10?api_key=MY_KEY would return ten results (the count parameter) as xml.

Re: [Tutor] how come this doesnt work

2011-01-15 Thread Alex Hall
On 1/15/11, Alan Gauld wrote: > "Alex Hall" wrote > >> m=int(m) >> just before the if statement. This causes m to turn from a string >> into >> an integer and is what is known as "casting" or "type casting", if I >> have my v

Re: [Tutor] how come this doesnt work

2011-01-14 Thread Alex Hall
On 1/14/11, walter weston wrote: > > I generate a random number(supposedly a password, in my case its just a long > floating point lol),I want the user to reinput that number and I want to > print a string if the number entered is correct. so if m==num(num is the > number generated and m is the va

Re: [Tutor] Object/Class Beginner Questions

2011-01-14 Thread Alex Hall
On 1/14/11, Ben Ganzfried wrote: > Hey guys, > > I'm using a tutorial geared for a 2.x version of Python and I am currently > using Python 3.1-- so it is possible that my confusion has to do with > different notations between them. But in any case, here is what I have: > type(Time) > t

Re: [Tutor] Odd result from function call

2011-01-07 Thread Alex Hall
Cast to an int: x=int(x) See if that helps. On 1/7/11, Ben Ganzfried wrote: > When I call one of my functions from the shell (ie compare(10, 5)) it > produces the correct output. However, when I run the program after calling > the method later in the script, the result is bizarre. I'm curious w

Re: [Tutor] wx accelerator table: one keystroke seems skipped

2011-01-06 Thread Alex Hall
On 1/6/11, Octavian Rasnita wrote: > From: "Alex Hall" >> Hello all, >> First, this is about a wx accelerator table, so if it is too off-topic >> for this list, let me know. >> >> I have a table with 23 entries, all of which work. I added another >

[Tutor] wx accelerator table: one keystroke seems skipped

2011-01-05 Thread Alex Hall
Hello all, First, this is about a wx accelerator table, so if it is too off-topic for this list, let me know. I have a table with 23 entries, all of which work. I added another entry last night, and it does not work. The odd thing, though, is that I do not get an error of any kind anywhere in the

Re: [Tutor] user input help

2011-01-05 Thread Alex Hall
On 1/5/11, Jason Staudenmayer wrote: > Hi all, I'm pretty new to programming in general and figured I'd try out > python. > I'm working on a small program to add users to a sqlite db. The problem I'm > having it dealing with the user input, I'd like to be able to repeat the > function to get the i

Re: [Tutor] print stack traces not caused by errors

2011-01-04 Thread Alex Hall
accelerator table). It is one of those problems that is hard to track down since it seems to happen randomly, though there is, of course, some set of circumstances causing the problem that I cannot figure out. I will get it eventually... hopefully! On 1/4/11, Alan Gauld wrote: > > &quo

[Tutor] print stack traces not caused by errors

2011-01-04 Thread Alex Hall
Hi all, I am coming along quite nicely with Solitaire (sans graphics). However, I am getting some odd behavior, and I would like to see what is calling what so I can see where things are going wrong. It is not causing an error to print a traceback, but it is not doing what I expected at all. I trie

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
On 1/3/11, Walter Prins wrote: > Sorry, my last post was too hasty. You also had a problem calling super. > It should be like this: > > class parent(object): > def __init__(self, l=None): >if l is None: self.l=[] >else: self.l=l > > class child(parent): > def __init__(self, *args, **kwo

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
On 1/3/11, Wayne Werner wrote: > On Mon, Jan 3, 2011 at 6:47 PM, Alex Hall wrote: > >> Hi all, >> I have a solitaire game in which I use a "Pile" class. This class is >> meant to hold a bunch of cards, so I subclass it for the deck, the ace >> stacks, a

[Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
Hi all, I have a solitaire game in which I use a "Pile" class. This class is meant to hold a bunch of cards, so I subclass it for the deck, the ace stacks, and the seven main stacks, defining rules and methods for each but also relying on the parent Pile class's methods and attributes. However, I k

Re: [Tutor] Problem with print

2010-12-19 Thread Alex Hall
Sorry to top-post (gMail mobile). This looks like you missed a quote, colon, or something on a line elsewhere in the file (likely above it). Find that and this should be fixed. On 12/19/10, jtl999 wrote: > File "GettingStarted.py", line 91 > print ("Lesson Two") > ^ > SyntaxError: in

Re: [Tutor] the "**" operator?

2010-12-10 Thread Alex Hall
Thanks all! I thought update() would add an item even if it would be a duplicate, but apparently not. I also now better understand why I am always passing around *args and **kwargs when calling super(). Very interesting... On 12/10/10, Hugo Arts wrote: > On Fri, Dec 10, 2010 at 8:14 PM, A

[Tutor] the "**" operator?

2010-12-10 Thread Alex Hall
Hi all, I was googling a way to do something like mydict=mydict.extend(additionaldict) and someone on a forum recommends this: mydict=dict(mydict, **additionaldict) What is the ** doing here? I tried to look it up, but Google seems to ignore it since it is punctuation. The poster on the forum says

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Thanks to all for the quick responses. Python always surprises me with its shortcuts... On 12/9/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> val=val or 1 > >> I am guessing that val is an int. If val==0, the 'or' kicks in and >> val=1,

[Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Hi all, I am reading the source of a project I hope to help with (http://www.qwitter-client.net). I sometimes see something like: val=val or 1 I am guessing that val is an int. If val==0, the 'or' kicks in and val=1, else the or is not needed and val=val. Am I close? Can other words or symbols be u

  1   2   >