Re: [Tutor] Variables in workspace

2007-10-15 Thread Alan Gauld
"Eli Brosh" <[EMAIL PROTECTED]> wrote > The dir() and del work really well ! I meant to add that if you look at the names a lot then you migt prefer PyCrust asa shell rather than IDLE. PyCrust has a small namespace window on permanent display wich shows all of the names dynamically in an ex

Re: [Tutor] upgrading Python

2007-10-15 Thread Alan Gauld
"LandSurveyor" <[EMAIL PROTECTED]> wrote > had never used a link before. Didn't know why I would want to. Links are super cool, you can do lots with them, just beware of circular references or things like tar or cp -r will go into endless loops! > and got as far as 'make', when it required me

Re: [Tutor] upgrading Python

2007-10-15 Thread Alan Gauld
"LandSurveyor" <[EMAIL PROTECTED]> wrote > a.. the digraphs I have incorporated from the Vim environment > into my scripts no longer work. Can you show us an example? > b.. Within my code, I have two adjacent 'try/except' sequences. Again can you show us the actual code segment? Its ha

Re: [Tutor] upgrading Python

2007-10-15 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > Why people even give MS any mind-share is beyond me For the same reason most people don't buy kit cars. Linux is a great hobbyist environment and if you want your OS to be a hobby then use Linux you will learn a lot about your computers. But if you jus

Re: [Tutor] 2 problems in a small script

2007-10-15 Thread Kent Johnson
Dick Moores wrote: >> If your interested, this could be done succinctly with set types. (no >> iterating required!) > Done. I had no idea set could be used that way! With a couple of > modifications, I used your ideas in both and > (see the thread I started, < > http://www.nabble.com/An-id

Re: [Tutor] File upload from python shell

2007-10-15 Thread Kent Johnson
Paulino wrote: > Hello! > > > How can I upload a file from python? > > If it is a form to fill with values it's simple: > > > urlopen("http://site.com/action?key1=value1;key2=value2";) and I get the > form filled. > > > What about uploading a file programmaticaly? This might help: http://

Re: [Tutor] upgrading Python

2007-10-15 Thread Kent Johnson
LandSurveyor wrote: > Some interesting (!?) things happened when I upgraded from Python 2.3 > to Python 2.5.1. My editor of choice is Vim, the platform is > MandrakeLinux 10.1... > > * the digraphs I have incorporated from the Vim environment into my > scripts no longer work. The re

Re: [Tutor] largest and smallest numbers

2007-10-15 Thread Kent Johnson
Dick Moores wrote: > I pinched it down some more (after dinner): > > >>> 1.79769313486e+308 * (1.001 ** 1160) > 1.7976931348623151e+308 > >>> 1.79769313486e+308 * (1.001 ** 1161) > 1.#INF This looks promising: In [8]: x=1.7976931348623157e+308 In [9]: y=0.000

[Tutor] Python

2007-10-15 Thread surendra kumar
Please give me details of python tution, Thanks surendra kumar - Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.___ Tutor maillist - Tutor@python.org http://mail.python.org/m

Re: [Tutor] upgrading Python

2007-10-15 Thread bhaaluu
Greetings, On 10/15/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "bhaaluu" <[EMAIL PROTECTED]> wrote > > > Why people even give MS any mind-share is beyond me > > For the same reason most people don't buy kit cars. > Linux is a great hobbyist environment and if you want your > OS to be a hobb

Re: [Tutor] Python

2007-10-15 Thread Kent Johnson
surendra kumar wrote: > Please give me details of python tution This is a mailing list for people who are learning python, and people who like to help others learn python. http://mail.python.org/mailman/listinfo/tutor Kent ___ Tutor maillist - Tutor@

Re: [Tutor] Python

2007-10-15 Thread bhaaluu
Greetings, On 10/15/07, surendra kumar <[EMAIL PROTECTED]> wrote: > Please give me details of python tution, Thanks > surendra kumar > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor Send your questions to the T

Re: [Tutor] upgrading Python

2007-10-15 Thread Kent Johnson
bhaaluu wrote: > On 10/15/07, Alan Gauld <[EMAIL PROTECTED]> wrote: >> "bhaaluu" <[EMAIL PROTECTED]> wrote >> >>> Why people even give MS any mind-share is beyond me > > No, I think that GNU/Linux is now way beyond 'hobbyist environment'. OK, I think that is enough Linux/Windows/Mac advocacy

Re: [Tutor] upgrading Python

2007-10-15 Thread Ricardo Aráoz
bhaaluu wrote: > Greetings, > > On 10/15/07, Alan Gauld <[EMAIL PROTECTED]> wrote: >> "bhaaluu" <[EMAIL PROTECTED]> wrote >> > So, you use PCs with MS-Windows, and Mac,... really, when was the > last time you took a look at GNU/Linux? My suggestion: Look up > a Linux User Group (LUG) in your loca

[Tutor] newbie question

2007-10-15 Thread Ramkumar Kashyap
Hi all, I have just started learning to program and am working through the Beginning Python from Wrox. I am working through one of the examples in the books on dictionaries. Here is the example. >>> menu_specials = {"breakfast" : "sausage and eggs", ... "lunch" : "split pea soup and garlic bread

[Tutor] itertools.izip question?

2007-10-15 Thread Iyer
I have a dictionary d = {0: array([0, 0], dtype=uint16), 1: array([1, 1], dtype=uint16), 2: array([2, 2], dtype=uint16), 3: array([3, 3], dtype=uint16)} or d = {0:d0,1:d1,2:d2,3:d3} d0, d1, d2 and d3 are numpy.ndarray type I wish to get the interleaved data by using outputdata = numpy.a

Re: [Tutor] newbie question

2007-10-15 Thread Trilok Khairnar
Either of the following should do it: print string.join([menu_specials[val] for val in menu_specials], ', ') or print string.join([menu_specials[val] for val in menu_specials.keys()], ', ') or print string.join([menu_specials[val] for val in ["breakfast", "lunch", "dinner"] ], ', ')

Re: [Tutor] itertools.izip question?

2007-10-15 Thread Kent Johnson
Iyer wrote: > > > I have a dictionary > > d = {0: array([0, 0], dtype=uint16), 1: array([1, 1], dtype=uint16), 2: > array([2, 2], dtype=uint16), 3: array([3, 3], dtype=uint16)} > or > d = {0:d0,1:d1,2:d2,3:d3} > > > d0, d1, d2 and d3 are numpy.ndarray type > > I wish to get the interleaved d

Re: [Tutor] newbie question

2007-10-15 Thread Evert Rol
Hi Ram, > Either of the following should do it: > > print string.join([menu_specials[val] for val in > menu_specials], ', ') > or > print string.join([menu_specials[val] for val in > menu_specials.keys()], > ', ') > or > print string.join([menu_specials[val] for val in ["breakfa

Re: [Tutor] newbie question

2007-10-15 Thread Trilok Khairnar
Thinking more about the solutions I posted, I have a couple of questions :-) 1]print string.join([menu_specials[val] for val in menu_specials], ', ') >> Will this use iterkeys() under the hood? 2]print string.join([menu_specials[val] for val in menu_specials.keys()], ', ') >> Given that a

Re: [Tutor] newbie question

2007-10-15 Thread Trilok Khairnar
> With this, and if you want to use your formatted print statements instead of the join, you could use something like > print "Specials: %s %s %s" % tuple(menu_specials.values()) which turns the output of menu_specials.values() (a list) into a tuple. > Disadvantage is that you'll need to know the

Re: [Tutor] newbie question (teaching you to fish?)

2007-10-15 Thread bob gailer
Ramkumar Kashyap wrote: > Hi all, > > I have just started learning to program and am working through the > Beginning Python from Wrox. > > I am working through one of the examples in the books on dictionaries. > Here is the example. > > >>> menu_specials = {"breakfast" : "sausage and eggs", > ...

Re: [Tutor] newbie question

2007-10-15 Thread Trilok Khairnar
I agree, was just trying to take home the point that if at all a format string must be used (for whatever obscure reason), then it is not necesssary to know beforehand the number of values in the dictionary (or the length of list of its values) in order to to build the format string. Hope that was

Re: [Tutor] newbie question

2007-10-15 Thread Luke Paireepinart
Trilok Khairnar wrote: >> With this, and if you want to use your formatted print statements instead >> > of the join, you could use something like > >> print "Specials: %s %s %s" % tuple(menu_specials.values()) which turns the >> > output of menu_specials.values() (a list) into a tuple

Re: [Tutor] newbie question

2007-10-15 Thread Alan Gauld
"Ramkumar Kashyap" <[EMAIL PROTECTED]> wrote > print "%s %s %s" % menu_specials["breakfast"], > menu_specials["lunch"], > menu_specials["dinner"] Whoops, I also should have added parentheses around the values. Otherwise Python sees a tuple consisting of the string and first value followed by the

Re: [Tutor] newbie question

2007-10-15 Thread Alan Gauld
"Ramkumar Kashyap" <[EMAIL PROTECTED]> wrote menu_specials = {"breakfast" : "sausage and eggs", > ... "lunch" : "split pea soup and garlic bread", > ... "dinner": "2 hot dogs and onion rings"} print "%s" % menu_specials["breakfast"] You don't really need the %s bit it could just be >>

[Tutor] (no subject)

2007-10-15 Thread Latasha Marks
Need help write a bowling progam for 10 frame have to print score and frames - Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV.___ Tutor maillist - Tutor@python.org h

[Tutor] Decimal Conversion

2007-10-15 Thread ddm2
Hi, I'm new to Python, and found some problems on the internet that would be a good start to begin. The problem I have is that my conversion program (which currently only converts unsigned integers) also prints all these brackets and commas. Here is my code and the result: CODE: print "" print "--

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
Use b+=","+r instead. That will add the , to the string named by b, and will concatenate the string named by r to the end. --Michael -- Michael Langford Phone: 404-386-0495 Consulting: http://www.TierOneDesign.com/ On 10/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm new

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
After sending the last email, I was more and more unsatisfied with it's level of detail I provided. Your original statement: b=b,r was doing nothing like you intended. The comma operator in this instance is making a tuple. The name b was being reassigned to the new tuple created by the comma ope

Re: [Tutor] Decimal Conversion

2007-10-15 Thread christopher . henk
However since r is an int and b is a string, you will get an error when you try and concatenate them. >>> b='' >>> b+=1 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects So you need to convert r to a string before you assign it to b >>

Re: [Tutor] newbie question

2007-10-15 Thread jon vspython
There's also a specially tailored solution for dictionaries: print "%(breakfast)s %(lunch)s %(dinner)s" % menu_specials ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] 2 problems in a small script

2007-10-15 Thread Dick Moores
At 04:36 AM 10/15/2007, Kent Johnson wrote: >Dick Moores wrote: > >>>If your interested, this could be done succinctly with set types. >>>(no iterating required!) > >>Done. I had no idea set could be used that way! With a couple of >>modifications, I used your ideas in both and >> (see the thre

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > print "" > print "" > print "Unsigned Binary" > print "" > print "" You don;t need the empty quotes to print a newline. In fact the whole of the above is easier done using triple quotes print """ Unsigned B

Re: [Tutor] newbie question

2007-10-15 Thread Alan Gauld
"jon vspython" <[EMAIL PROTECTED]> wrote > There's also a specially tailored solution for dictionaries: > > print "%(breakfast)s %(lunch)s %(dinner)s" % menu_specials Good catch! I keep forgetting about that. I really must get into the habit of using it more often when working with dictionari

Re: [Tutor] (no subject)

2007-10-15 Thread Alan Gauld
"Latasha Marks" <[EMAIL PROTECTED]> wrote > Need help write a bowling progam for 10 frame have to print score > and frames Please, don't just reply to another message (especially one with No Subject!), start a new thread and provide a sensible subject.It makes it much more likely that your mes

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Michael Langford
>Michael has already explained that this is building >a tuple of tuples. But you want to create strings. >So first convert r to a string using str(r) Yeah sorry about thatread some java over the weekend (source code to http://reprap.org)...and then munged some of its syntactic sugar into the p

Re: [Tutor] Help with packages and namespaces please

2007-10-15 Thread Andrew Wu
Hmmm ... thank you very much for the detailed explanations. This is a very simplified version of some actual code I'm currently using and attempting to rework on each individual file (about 60+ of them). If it's not feasible then I guess I'm stuck with the rework. =( More comments inline ... O

Re: [Tutor] Timers in Python

2007-10-15 Thread Kamal
Thanks everyone for the useful feedback. On 10/4/07, Noufal Ibrahim <[EMAIL PROTECTED]> wrote: > > Kent Johnson wrote: > > Kamal wrote: > >> hello everyone, > >> > >> Is there a method in Python which does what > >> setInterval('someFunction()',5000) does in Javascript. > >> > >> Basically, I want

Re: [Tutor] File upload from python shell

2007-10-15 Thread Paulino
Kent Johnson escreveu: > Paulino wrote: >> Hello! >> >> >> How can I upload a file from python? >> >> If it is a form to fill with values it's simple: >> >> >> urlopen("http://site.com/action?key1=value1;key2=value2";) and I get >> the form filled. >> >> >> What about uploading a file programmatic

Re: [Tutor] Help with packages and namespaces please

2007-10-15 Thread Andrew Wu
After a more careful perusing and sifting of your response, I discovered this helped my understanding a lot better: > > You can bring names into the package namespace, but the actual code will > still run in the module where it is defined. For example, in > PrintMe/PrintBase/__init__.py you can s

Re: [Tutor] Decimal Conversion

2007-10-15 Thread Luke Paireepinart
Michael Langford wrote: > > >Michael has already explained that this is building > >a tuple of tuples. But you want to create strings. > >So first convert r to a string using str(r) > > Yeah sorry about thatread some java over the weekend (source code > to http://reprap.org)...and

[Tutor] __getattr__(): Is this right?

2007-10-15 Thread Allen Fowler
I seem to be having an issue with __getattr__() being called even if the proporite already exists... I thought that this was not supposed to happen. Is there a typo somewhere, or I do i misunderstand things? class someclass(object): def __init__(self, **kargs): self.val

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Kent Johnson
Allen Fowler wrote: > I seem to be having an issue with __getattr__() being called even if the > proporite already exists... I thought that this was not supposed to happen. > > Is there a typo somewhere, or I do i misunderstand things? > > class someclass(object): > > > def __init__(se

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Eric Brunson
Allen Fowler wrote: > I seem to be having an issue with __getattr__() being called even if > the proporite already exists... I thought that this was not supposed > to happen. I think you've misunderstood. __getattr__() should always be called, it allows you to intercept and reimplement the beha

[Tutor] All Apress Titles 50% off sale

2007-10-15 Thread Dick Moores
That includes some titles that aren't out yet, such as: The Definitive Guide to Django: Web Development Done Right Beginning Game Development with Python and Pygame: From Novice to Professional

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Allen Fowler
Eric Brunson <[EMAIL PROTECTED]> wrote: Allen Fowler wrote: > I seem to be having an issue with __getattr__() being called even if > the proporite already exists... I thought that this was not supposed > to happen. I think you've misunderstood. __getattr__() should always be called, it allows

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Eric Brunson
Allen Fowler wrote: > > > */Eric Brunson <[EMAIL PROTECTED]>/* wrote: > > Allen Fowler wrote: > > I seem to be having an issue with __getattr__() being called > even if > > the proporite already exists... I thought that this was not > supposed > > to happen. > > I think

Re: [Tutor] __getattr__(): Is this right? [w/ new code]

2007-10-15 Thread Allen Fowler
What did you try? What happened? What did you expect? Kent Narrowed things down a bit. Given this class: --- class sc(object): def __init__(self, **kargs): self.valid_props = [ 'foo', 'bar', 'baz' ] for prop in self.valid_props:

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Allen Fowler
> "Note that if the attribute is found through the normal mechanism, > __getattr__() is not called. (This is an intentional asymmetry between > __getattr__() and __setattr__().) This is done both for efficiency > reasons and because otherwise __setattr__() would have no way to > access other

[Tutor] reading POST method in cgi script

2007-10-15 Thread Eric Abrahamsen
I'm trying to learn the fundamentals of cgi scripting, before moving on to actually using the cgi module and, eventually, mod_python. I've grasped that, if users submit a form to my cgi script, I can read the form contents from os.environ['QUERY_STRING'] if it was stuck in the URL via metho

Re: [Tutor] __getattr__(): Is this right? [w/ new code]

2007-10-15 Thread Allen Fowler
Umm... well. obviously I left out an __setattr__() call.. sigh. thanks anyway... Allen Fowler <[EMAIL PROTECTED]> wrote: What did you try? What happened? What did you expect? Kent Narrowed things down a bit. Given this class: --- class sc(object): de

Re: [Tutor] reading POST method in cgi script

2007-10-15 Thread Luke Paireepinart
Eric Abrahamsen wrote: > I'm trying to learn the fundamentals of cgi scripting, before moving > on to actually using the cgi module and, eventually, mod_python. I've > grasped that, if users submit a form to my cgi script, I can read the > form contents from os.environ['QUERY_STRING'] if it w