Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Kent Johnson
Alan Gauld wrote: > "Dick Moores" <[EMAIL PROTECTED]> wrote > >> Could you give a blow-by-blow on the dis.dis()? > > I'll have a go but I've never actually studied Python P-Code, > this is based on my 8080 and 68000 assembler experience! Some hits, some misses. I'll correct to the best of my k

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Marc Tompkins
On Mon, Apr 7, 2008 at 4:52 PM, Alan Gauld <[EMAIL PROTECTED]> wrote: > "Dick Moores" <[EMAIL PROTECTED]> wrote > > > Could you give a blow-by-blow on the dis.dis()? > > I'll have a go but I've never actually studied Python P-Code, > this is based on my 8080 and 68000 assembler experience! > ... >

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > Could you give a blow-by-blow on the dis.dis()? I'll have a go but I've never actually studied Python P-Code, this is based on my 8080 and 68000 assembler experience! > In [22]: def f(x): > : if x%2: > : return "odd" > :

Re: [Tutor] dis.dis (was: PyMOTW: difflib)

2008-04-07 Thread Kent Johnson
Dick Moores wrote: > Could you give a blow-by-blow on the dis.dis()? That's a bit more than I have time for ATM but it's not really that hard to at least get a general understanding of what is going on. Here is a list of the bytecode instructions that may help: http://docs.python.org/lib/byteco

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Dick Moores
At 02:57 PM 4/7/2008, Dick Moores wrote: This may be pushing it with you, but I found the dis.dis() thing fascinating. Here's a bit more complex function.  def f(x): if x%2: return "odd" else: return "even" Could you give a blow-by-blow on the dis.dis()? ==

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Dick Moores
At 12:33 PM 4/7/2008, Kent Johnson wrote: In [13]: import dis In [15]: def foo():     : a = 10 In [16]: dis.dis(foo)    2   0 LOAD_CONST   1 (10)    3 STORE_FAST   0 (a)    6 LOAD_CONST   0 (None)    9 RETURN_

[Tutor] C# defaultdict question

2008-04-07 Thread GTXY20
Hello all, Sadly I need to convert a great python application into C# .Net. I have been pretty successful so far but I was wondering if anyone knew of something similar to a python defaultdict(int) in C#. In python I am doing: g = {} (where the value in the key value pair is a tuple of values) f

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Kent Johnson
Jerrold Prothero wrote: > > I've been trying to understand how writing a dictionary to a file & reading > it back should work. > > It's been suggested that if I had a clue, I'd use pickle, but since I > started > looking at the csv (comma separated values) module, which also supports > writing

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Kent Johnson
Luke Paireepinart wrote: > You mean that the dictionary _definition_ ignores whitespace between > elements? > > That's not a feature of dictionaries, but of the comma. > You can easily do the following: > x = [1, 2, >3, 4] > if you want. > Same with tuples and various other things. > Pyt

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
On Mon, Apr 7, 2008 at 10:53 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Also, did you test the code that "generates an error?" > It works fine for me. > >>> foo = {'1a': 'b'} > >>> foo['2b'] = 0 > >>> print foo['2b'] > 0 > >>> You're missing 4 spaces in front of foo['2b'] = 0, and h

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Kent Johnson
Alan Gauld wrote: > "Dick Moores" <[EMAIL PROTECTED]> wrote >> Is a name the same as anything defined? > > Yes pretty much anything that has a name. > > Its worth spending the time reading and playing with > this because its a fundamental concept in Python > and once understood many of the s

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Jerry Hill
On Mon, Apr 7, 2008 at 1:09 PM, Jerrold Prothero <[EMAIL PROTECTED]> wrote: > Relevant Python 2.5 documentation sections are 9.1.1 and 9.1.4. My > question boils down to this: what does writerows want as an argument > for a dictionary? A list of dictionaries. One dictionary for each row you would

[Tutor] Re: glade integration

2008-04-07 Thread tannhauser
http://gazpacho.sicem.biz/ has a build for windows. th ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] glade integration

2008-04-07 Thread Michael Langford
I've also tried to use XRCed, but it crashes more often then a paper airplane, at least on Windows Vista. (XRC files are a XML layout manager interface that can be loaded by wxPython to separate GUI from code). If anyone knows a nice XRC builder, that would suffice. --Michael On

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Alan Gauld
"Jerrold Prothero" <[EMAIL PROTECTED]> wrote > It's been suggested that if I had a clue, I'd use pickle Shelve is based on Pickle and makes a file look somewhat like a dictionary. It might do all you need and is a standard module. > looking at the csv (comma separated values) module, which also

Re: [Tutor] create new user

2008-04-07 Thread Alan Gauld
"root" <[EMAIL PROTECTED]> wrote > I want to write a python script in which will create a new user and > password.please tell me ,how it will be passible??? It depends on how you are building your web app. If you are using TurboGears as your framework then it provides user admin (and securit

Re: [Tutor] glade integration

2008-04-07 Thread Alan Gauld
"Michael Langford" <[EMAIL PROTECTED]> wrote > While on the topic of glade, does anyone know of a working gui > builder for > glade on windows? WinGlade appears to have been linkjacked or > hacked. > --Michael I tried several free or shareware/trialware GUI builders for wxPython. None

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > I'm having trouble with the concept of a name in Python. > > Is a name the same as anything defined? Yes pretty much anything that has a name. It could be a variable, a class, a module, a function, anything that you can refer to or can refer to an ob

Re: [Tutor] glade integration

2008-04-07 Thread Michael Langford
Well there you go. Just needed to look elsewhere: http://sourceforge.net/project/showfiles.php?group_id=98754 On Mon, Apr 7, 2008 at 1:59 PM, Michael Langford < [EMAIL PROTECTED]> wrote: > While on the topic of glade, does anyone know of a working gui builder for > glade on windows? WinGlade app

Re: [Tutor] glade integration

2008-04-07 Thread Michael Langford
While on the topic of glade, does anyone know of a working gui builder for glade on windows? WinGlade appears to have been linkjacked or hacked. --Michael On Mon, Apr 7, 2008 at 11:07 AM, tannhauser <[EMAIL PROTECTED]> wrote: > On Mon, 07.04, 09:48, Luke Paireepinart wrote: > > Michael M

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Dick Moores
At 12:23 AM 4/7/2008, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote in message > > > Even if there weren't a path problem, my understanding is that > > from difflib_data import * would only import the functions in > > difflib_data.py; There are none. > >import imports names. Any name

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Luke Paireepinart
Jerrold Prothero wrote: > > I've been trying to understand how writing a dictionary to a file & > reading > it back should work. > [snip] > > Here are three guesses at how to call writerows, with error traces. > [snip] > 2) > > w.writerows(d) > > Traceback (most recent call last): > Fi

[Tutor] Writing dictionaries to a file

2008-04-07 Thread Jerrold Prothero
I've been trying to understand how writing a dictionary to a file & reading it back should work. It's been suggested that if I had a clue, I'd use pickle, but since I started looking at the csv (comma separated values) module, which also supports writing dictionaries out to a file, I at least want

Re: [Tutor] MemoryError !!! Help Required

2008-04-07 Thread Andreas Kostyrka
Hint: MemoryError suggests that his dicts have filled up his address space (probably). 1-3GB on Linux, 2?GB on Windows. At least for 32bit versions. So storing the whole URL in memory is probably out of question, storing it only in some form of files might be slightly slow, so one compromise would

Re: [Tutor] Question about global variables on modules

2008-04-07 Thread Dave Kuhlman
On Fri, Apr 04, 2008 at 10:25:30PM -0300, Tiago Katcipis wrote: > I know its not such a pretty thing to have global variables but its only > for an exercise my teacher told to do. Its a function to calculate the > results of a matrix using jacob. I want to inside the module (inside a > function on

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Andrei Petre
A good place to look at : http://www.norvig.com/sudoku.html On Mon, Apr 7, 2008 at 6:53 PM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > W W wrote: > > On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > > >> W W wrote: > >> What are you talking about? I don't understand what you mean

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Luke Paireepinart
W W wrote: > On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > >> W W wrote: >> What are you talking about? I don't understand what you mean by "ignores >> whitespace between dictionary elements." >> >> >>> foo = {'1a': 1, '1b':2, '1c':3, >>> '2a': 0, '2b': 9, '2c': 6} >

[Tutor] Re: glade integration

2008-04-07 Thread tannhauser
On Mon, 07.04, 09:48, Luke Paireepinart wrote: > Michael Miesner wrote: > > Hi- > > I am totally new to python and I cant figure out how to integrate a > > glade file into a python file. Is it as simple as referencing the > > glade file, or must the XML code from the glade file be copied in? > >

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > W W wrote: > What are you talking about? I don't understand what you mean by "ignores > whitespace between dictionary elements." > > > foo = {'1a': 1, '1b':2, '1c':3, > > '2a': 0, '2b': 9, '2c': 6} Exactly that. If you were to w

Re: [Tutor] Code optmisation

2008-04-07 Thread Eric Walstad
Hi Yogi On Fri, Apr 4, 2008 at 10:05 PM, yogi <[EMAIL PROTECTED]> wrote: > Hi , >Here is my first usable Python code. > The code works. Woohoo! congratulations. > Here is what I'm trying to do. > I have two huge text files. After some processing, One is 12M (file A) and > the other

Re: [Tutor] Creating Sudoku

2008-04-07 Thread Luke Paireepinart
W W wrote: > Actually, a dictionary might be a good idea. > I just played with this so youcan get a little picture. > [snip] > > You could easily run int(val) to convert to the integer value to store > in the dict. The other benefit is that python ignores whitespace in > between dictionary elements

Re: [Tutor] glade integration

2008-04-07 Thread Luke Paireepinart
Michael Miesner wrote: > Hi- > I am totally new to python and I cant figure out how to integrate a > glade file into a python file. Is it as simple as referencing the > glade file, or must the XML code from the glade file be copied in? > Sorry to ask such a basic question. XML is how glade stores

Re: [Tutor] MemoryError !!! Help Required

2008-04-07 Thread W W
I don't have a lot of experience, but I would suggest dictionaries (which use hash values). A possible scenario would be somthing similar to Andreas' visited = dict() url = "http://www.monty.com"; file = "/spam/holyhandgrenade/three.html" visited[url] = file unvisited = dict() url = "http://

Re: [Tutor] Code optmisation

2008-04-07 Thread Kent Johnson
yogi wrote: Some small optimizations inline, more important comments after the code. > #/bin/python > import sys, os, csv, re > x = 0 #Define Zero for now > var = 100 #Taking the variation > # This programme finds the SNPs from the

Re: [Tutor] Creating Sudoku

2008-04-07 Thread W W
Actually, a dictionary might be a good idea. I just played with this so youcan get a little picture. >>> foo = {'1a': 3, '1b': 4} >>> row = raw_input("Row: ") Row: 1 >>> col = raw_input("Column: ") Column: b >>> val = raw_input("Value: ") Value: 1 >>> foo[row+col] = val >>> foo {'1a': 3, '1b': '1'

[Tutor] glade integration

2008-04-07 Thread Michael Miesner
Hi- I am totally new to python and I cant figure out how to integrate a glade file into a python file. Is it as simple as referencing the glade file, or must the XML code from the glade file be copied in? Sorry to ask such a basic question. ___ Tutor mail

[Tutor] create new user

2008-04-07 Thread root
Hi All. Hope you are Good and Doing Well.I am Working on a web based application .I need your pretty help for this all as I have to work in Python and I am New to this.. I want to write a python script in which will create a new user and password.please tell me ,how it will be passible??? I

Re: [Tutor] PyMOTW: difflib

2008-04-07 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote in message > Even if there weren't a path problem, my understanding is that > from difflib_data import * would only import the functions in > difflib_data.py; There are none. import imports names. Any names, not just functions. After all, function

Re: [Tutor] socket / over network

2008-04-07 Thread Alan Gauld
"Nathan McBride" <[EMAIL PROTECTED]> wrote > Going off of wha tyou said, if I choose to use ftp, is there a way i > could do everything from within python including the server to get > the > files? Is there like a ftp module for python to help in the passing > of > the files between the comput