2009/11/20 :
> Hey Gang,
>
> Can a function/method be added to a dictionary like so:
>
> myDictionary = {"string":processString(parameter),
> "string2":processString2(parameter),
> "string3":processString3(parameter)
> }
>
> I am basically interested in
2009/6/23 Alan Gauld :
> Interesting! How is a NaN stored in Python?
> ie. How do you get to the point of having one in the first place?
Well, you can do this:
>>> float('nan')
nan
(try float('inf') too)
--
John.
___
Tutor maillist - Tutor@python.o
2009/6/13 Eddie :
> Hi guys,
>
> What would you regard as the best free Python editor to use on Windows
> for a new guy? Searching Google i see that there is quite a few out
> there and is "VIM" the best one to go with?
Vim is a general purpose programmer's editor with python support,
rather than
2009/6/12 acfleck :
> I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a
> default install of MacPython 3.0.1. The IDLE.app works fine, but from a
> Terminal window, the 'python' command still gets me V2.5.3 (the original
> Apple installed version). A 'python3' command is no
2009/5/26 Eduardo Vieira :
> Now, a little farther on the topic of a Bible database. I'm not sure
> how I should proceed. I don't really have the db file I need, I will
> have to generate it somehow, from a bible software, because the
> version I want is for Portuguese. I have found a bible in sql,
2009/5/22 Eduardo Vieira :
> I will be looking for lines like these:
> Lesson Text: Acts 5:15-20, 25; 10:12; John 3:16; Psalm 23
>
> So, references in different chapters are separated by a semicolon. My
> main challenge would be make the program guess that 10:12 refers to
> the previous book. 15-20
2009/5/12 nickel flipper :
> sfr (key=PORTA addr=0xf80 size=1 access='rw rw rw u rw rw rw rw')
> reset (por='' mclr='')
> bit (names='RA7 RA6 RA5 - RA3 RA2 RA1 RA0' width='1 1 1 1 1 1 1 1')
> bit (tag=scl names='RA' width='8')
> bit (names='OSC1 OSC2 AN4 - AN3 AN2 AN1 AN
2009/3/31 james carnell :
> for row in range(25,31,1):
> for col in range(10,12, 0.3): #<- Crash Bang doesn't work 0.3 = zero =
> infinite loop?
> [...]
> is there no way to do it with a range function (and have it still look like
> you're not on crack)?
Well, you could do this:
>>> [float(x
2009/3/30 Chris Castillo :
> yeah that function would help but how would I join both sides again to get a
> decimal real(float) to round?
>
> for example myfloat = decnum1, ".", decnum2 doesn't work because the string
> "." isn't a valid int type. how would I join those to be a float again?
The ea
2009/3/30 Chris Castillo :
> that is what I have so far but I need to create a condition where I need
> only 10 sufficient numbers from the variable decnum2. I know I need
> something like
> if len(decnum2) > 11:
> decnum2 = decnum2[0:11]
Perhaps the round() function will help?
>>> round(1234
2009/3/20 andré palma :
> Hi \o
> I'm asking if there is any #include( C) like or any include('File.php')
> (php) like in python.
> I have 2 files: "usbconnection.py" and "listen.py", And i want to use some
> classes avaiable in "listen.py" on my main file "usbconnection.py". I've
> tryed to do __i
2009/3/19 Alexander Daychilde (Gmail) :
> That creates a list of numbers. I also need to do letters. That is, treat
> a-z as base 26, and do the same thing. The three examples I gave from before
> would be:
> 1:9 --> a:z
> 1:99 --> a:zz
> 01:99 -- no "zero" in alpha to worry ab
2009/3/18 Wayne Watson :
> Not at all. I took Grayson's example as it stood. However, as it might have
> been noted above, he was working with Pmw, so the code may be a false
> impression of how it works in Tkinter.
>
> This gave the same results:
> root = Tk()
> dialog = DialogPrototype(root)
> ro
2009/3/18 Wayne Watson :
> Unfortunately, that takes me back to the original situation. That is, the
> blank window appears along with the dialog window. It also ends badly with
> what looks like the same error messages(below). Maybe focus needs to be
> established. I'm really using this code to de
2009/3/9 WM. :
> Thank you for your remarks. Too bad they fell into my acres of ignorance.
> One thing is certain, Dawson used brackets [] not parens (). When I spoke of
> typi (plural of typo) I meant ; for : or \ for /, not line after line of
> error.
> My only alternative now seems to be 'get ou
2009/3/9 WM. :
> File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
> print "\n\t", board[1], "|", board[2], "|", board[3]
> TypeError: 'function' object is unsubscriptable
>
> I am fooling around with Dawson's "...for the Absolute Beginner". The
> tic-tac-toe program will not run for m
2009/3/3 Wayne Watson :
> What is this: d = [ int(x) for x in s.split(":") ]
It's a list comprehension:
http://docs.python.org/tutorial/datastructures.html#list-comprehensions
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mail
2009/3/3 Judith Flores :
>
> Hello,
>
> I can't seem to figure out the syntax to calculate the difference in
> minutes between two time stamps. I already read the documentation about
> datetime and time modules, but I was unable to implement the code.
>
> My code will be fed with two timestamps
2009/2/27 prasad rao :
> Hello
> I don't know why, but this I think going into infinite loop.
> I cant see anything wrong in it.
> Please show me where the problem is.
[...]
> while len(line)>60:
> tem=line[60:]
> try:
> ??? a,b=tem.split(' ',1)
> ?
2009/2/19 pa yo :
> I am running my Twitter>>Wiki bots in infinite loops but can't find
> an easy way to turn them off gracefully once I have started them. At
> the moment I have to go into the terminal window where they are
> running and type "Ctrl-C". (I am running Ubuntu 8.10 and python 2.5.2)
2009/2/16 Alan Gauld :
> for index, item in [9,8,7,6]:
> print index, item
>
>
> 0 9
> 1 8
> 2 7
> 3 6
You mean:
for index, item in enumerate([9,8,7,6]):
print index, item
:-)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/
2009/2/13 Eric Dorsey :
> Alan, can you give a short snippet of what that would look like? I was
> trying to code out some idea of how you'd retain insertion order using
> another dict or a list and didn't get anywhere.
Here's something basic:
class o_dict(dict):
def __init__(self, *args, **
2009/2/13 Ricardo Aráoz :
> There are a couple of utilities I want to be able to run from the
> command window. Now, if I'm at the command window, or Idle, or other non
> wx shell I want to establish a wx app. But if I'm in pythonWin, PyCrust,
> or any other wx based shell then there is a wx event
2009/2/10 David :
> Dear list,
>
> out of "Thinking in Python" I take the following code, which
> "takes a word and a string of required letters, and that returns True if
> the word uses all the required letters at least once".
>
>
> def uses_all(word, required):
>for letter in required:
>
2009/2/3 David :
> while(doit):
>mytime = list(time.localtime())
>hour = mytime[3]
>minute = mytime[4]
>if hour == alarmhour and minute == alarmmin:
>subprocess.call('mplayer -loop 9 ring.wav', shell=True)
>sys.exit()
Hi David,
What
2009/2/3 Tim Johnson :
>> - wrong libraries
> how do we resolve paths to libraries?
Well, like I suggested, you could try building a staticly-linked
version. Then it doesn't matter.
Otherwise, I'm not sure. Maybe you could figure out what libraries
you need, upload them, and play around with
2009/2/3 Tim Johnson :
> I have a client who is hosting under virtual domain services that do not
> provide python.
> He has unlimited disk space available ( or so the hoster says) and they
> would allow installation of binaries in the virtual domain via ftp.
>
> It's a linux 'box' with a /private
2009/1/29 col speed :
[...]
> What I expected "mult" to do was (somehow)to work out what the powers of
> the prime factors would be. Another reason I didn't think it was "mul" is
> the part that says " prime_factors_mult(n)" as the prime_factors function
> is just "prime_factors(n)" - without th
2009/1/28 col speed :
> Hello there,
> I got the following function while googling:
>
> def totient(n):
> """calculate Euler's totient function.
>
> If [[p_0,m_0], [p_1,m_1], ... ] is a prime factorization of 'n',
> then the totient function phi(n) is given by:
>
> (p_0 - 1)*p_
2009/1/26 Donna Ibarra :
> I need to write a program that implements Newton's method
[...]
What problems are you having?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
2009/1/23 Wayne Watson :
> Continuing. The code that is eventually used to do the save is:
> ===
> def SaveGIF(self):
> if self.current_path:
> default_path = splitext(basename(self.current_path))[0] + ".gif"
> path = asksaveasfilename(defaultext
2009/1/23 Wayne Watson :
> What I'm getting at it is when I see something in a program as:
> path = asksaveasfilename(defaultextension=".jpg",
> title="Save as JPEG",
> initialfile=default_path,
>
2009/1/23 Wayne Watson :
> And if I pass it, 'pcx', 'fits', 'dog', 'cat', ...?
I don't understand your question. You can certainly do this:
tkFileDialog.asksaveasfilename(filetypes=[('PCX files', '*.pcx'),
('FITS files', '*.fits'), ('Dogs', '*.dog')])
If that's not what you want, you need to ex
2009/1/23 Wayne Watson :
> How do I know what file types are available for asksaveasfilename? Suppose
> one isn't available, for example, FITS. How do I get it?
You pass the file types as an argument to the function.
tkFileDialog.asksaveasfilename(filetypes=[('Text', '*.txt'), ('Stuff',
'*.stf'),
2009/1/20 Emad Nawfal (عماد نوفل) :
> Hello tutors,
> I need to find the shortest / longest word(s) in a sequence of words. I've
> done this and it works, but I'm wondering whether this is a good way:
words = "man woman children he".split()
words
> ['man', 'woman', 'children', 'he']
2009/1/20 W W :
> So, I'm curious about this whole python 3k thing. Is python migrating to 3k
> only? Will 2.x no longer be "officially" supported?
Python might be transitioning to 3.0, but the full migration will take
years. Python 2.6 is not going away -- in fact, I see on python.org
that new v
2009/1/16 Ishan Puri :
> Hi,
> I was wondering if anyone could tell me where I can get corpora
> containing IMs, or blogs or any internet communication? This is kind of
> urgent.
Have you tried the enron email dataset? http://www.cs.cmu.edu/~enron/
(google may turn up other links)
--
John.
_
2009/1/14 Damon Timm :
> On Tue, Jan 13, 2009 at 8:55 PM, Steve Willoughby wrote:
>> This is playing a dangerous game, though, of introducing a race condition.
>> Is there nothing on the standard input RIGHT NOW because the source on
>> the other end of the pipe hasn't managed to generate anythin
2009/1/14 Damon Timm :
> This works when I do have something coming via stdin ... but if I run
> the script without piping something first ... it just sits there (I
> assume, waiting for some stdin) ...
>
> How do I tell it: if there is no stdin, just move on?
This might work:
import select, sys
2009/1/14 Jon Crump :
b = """{"aKey" : "a value with \"literal quotes\" in it"}"""
eval(b)
>
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 1
>{"aKey" : "a value with "literal quotes" in it"}
> ^
> SyntaxError: invalid s
2009/1/13 Judith Flores :
> Hello,
Hi Judith,
> 1. When I run the code above for the first time, the contents of the
> pre-existing file disappear, if I
> run the script a second time, now I can see the value of x.
This is a consequence of this line:
> outfile=open('template.csv','w') # Th
2009/1/9 Jonathan Balkind :
> Hi tutor list,
> I haven't been programming for long with Python, and I'm currently trying to
> make a simple game using Tkinter. I was wondering whether it is possible to
> submit a function to the mainloop so it will run every time the loop goes
> around? I thought a
On 12/12/2008, spir wrote:
> I just found a simple, but nice, trick to make regexes less unlegible.
> Using substrings to represent sub-patterns. E.g. instead of:
[...]
Another option is to use the re.VERBOSE flag. This allows you to put
comments in your regular expression and use whitespace fo
On 09/12/2008, Damon Timm <[EMAIL PROTECTED]> wrote:
> Basically: how do I make it match *.flac ? I couldn't find anything
> on google (searching for "python index" just gets me a lot of indexes
> of python docs - wink)
Hi Damon,
The fnmatch module will help here. It basically implements uni
On 04/12/2008, Michele Alzetta <[EMAIL PROTECTED]> wrote:
> I have been thinking about a problem, and I'm wondering what the best
> approach for a pythonic solution would be.
> The actual problem is very complex, but the very first step in the
> solution would be to come up with a simple way of
On 04/12/2008, Tim Michelsen <[EMAIL PROTECTED]> wrote:
> Hello,
> is there any possibility in python to retrieve the system wide internet
> connection settings?
>
> I would like to access the proxy settings stored in
> Internet Explorer -> Extras -> Options -> Connection -> LAN settings.
Insta
On 02/12/2008, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> I would like to use a try except to see if a value exists. But, when I use
> the following, if a does not exist it exits. I understand why this does
> this, but is there a way to get b,c, and d if a does not exist without using
> a try exc
On 02/12/2008, WM. <[EMAIL PROTECTED]> wrote:
> I recently asked a question about 'for' loops, expecting them to be similar
> to 'for-next' loops. I have looked at several on-line tutors but am still
> in the dark about what 'for' loops do.
> Does anyone have a plain English about the use of 'for
On 26/11/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
> You could use eval to evaluate the string but that would be dangerous since
> the striong could be a malicious piece of code. But you can make it a lot
> safer by wrapping it in a function with known effect, thus:
>
> s = "[2.5,2.8]" # your
2008/11/7 Ertl, John C CIV 63134 <[EMAIL PROTECTED]>:
> The idea is as I step through a list I want to use a different function
> (same name but from a different module) for each element in the list. How
> do I have a generic way to do this.
>
> for example for point 1 I want to use the rain funct
2008/11/7 aivars <[EMAIL PROTECTED]>:
> I use python 2.5.2.2 (activestate), WinXP, sqlite version 3.6.2
Hi Aivars,
I believe python has its own built-in sqlite, rather than using the
version you installed independently. So it is possible that the
python version of sqlite is older than 3.6.2 and
2008/11/6 Brian Lane <[EMAIL PROTECTED]>:
> But you could also compare it to a known type:
>
> if not type(price) is type(decimal.Decimal(0)):
> print "Not Decimal"
Easier to just compare with decimal.Decimal:
>>> import decimal
>>> d = decimal.Decimal(13)
>>> type(d) == decimal.Decimal
True
--
2008/11/6 Christopher Spears <[EMAIL PROTECTED]>:
> I inserted this code snippet into the Spaceship class:
>
> self.rect = self.image.get_rect()
> print self.rect
> self.rect = self.rect.inflate(-50, -50)
> print self.rect
>
> The following was printed to my console:
> >
> >
>
> I'm assuming that t
2008/10/31 <[EMAIL PROTECTED]>:
> Hi tutors.
>
> Is there a way to remap a tab key to enter a user-specified number of spaces
> in a Tkinter text widget instead of a genuine tab? An internet search has
> turned up zilch. The tab option in a text widget lets you enter the number of
> centimeters
2008/10/16 Wayne Watson <[EMAIL PROTECTED]>:
> That's the question in the Subject. Can Idle tell me? I see a Path Browser.
You could check the __version__ attribute. Not all modules provide it, though.
(e.g.: import pickle ; pickle.__version__ )
--
John.
___
2008/10/16 Emad Nawfal (عماد نوفل) <[EMAIL PROTECTED]>:
> One more question,
> I'm a linguistics person, I know some Java and some Python (and failed to
> learn Prolog). What things do I need to learn to write such "difficult"
> scripts? Are there any recommendations? books, certain things to learn
2008/10/16 Emad Nawfal (عماد نوفل) <[EMAIL PROTECTED]>:
> The focus letter will always be # 6 on the line. A is not a short vowel,
> and it is not followed by a short vowel, so the last character should be
> "_", not a "u"
Oh, I see. I misunderstood the meaning of "followed by". I can fix
that
2008/10/7 Deitemeyer, Adam R <[EMAIL PROTECTED]>:
> I'm a beginner Python user and I have simple python issue I can't seem to
> solve. I want to do a truth test on a string to see if a another string is
> contained within it. I found that typically the re module has the methods
> to accomplish th
2008/10/3 Glen Clark <[EMAIL PROTECTED]>:
> What is toplevel? Is it the same as Tk()? Do I initialise a root using Tk()
> and then use toplevel for any other windows? How do I switch between the
> Windows? And while I am on the subject what is a frame and why should I use
> it? atm the moment it ju
2008/9/29 <[EMAIL PROTECTED]>:
> I am writing a large Python/Tkinter/Pmw program. It has become so big that I
> would like to move some of the widget handlers to a module for import. The
> following small program illustrates:
>
> # --- begin code ---
[...]
>c = Checkbutton(
>
2008/9/24 Joe Python <[EMAIL PROTECTED]>:
> Hi Pythonistas,
>
> I have a large dictionary of dictionary (50,000+ keys) which has a structure
> as follows:
[snip]
> I want to sort the dictionary by 'income'
> Is there an efficient way to do the same.
Note that you cannot sort a dictionary. The bes
2008/9/17 Che M <[EMAIL PROTECTED]>:
>> (heck, you could select code, start, style form codes -- pull all the
>> information you need in a single query, and skip the loop
>> altogether..)
> I think I need the loop because the style will be multiple styles and
> I need to take the codes that go with
2008/9/16 Che M <[EMAIL PROTECTED]>:
> for style in self.style_list:
>
> #Get the codes...
> cur.execute('SELECT code FROM Codes WHERE code != "" AND Style= "' +
> style + '"
> AND start >=' + '"' + self.start_datestring + '"' + 'AND start < "'
> + self.end_datestring + '"')
> m
2008/9/11 J. Van Brimmer <[EMAIL PROTECTED]>:
> This should be enough to get you started. You'll just have to jump in and
> read, read, and read. :-)
I would say: jump in and code, code, and code. Reading's easy, but if
you're anything like me, you'll learn more through doing. The best
thing a t
2008/9/8 Wayne Watson <[EMAIL PROTECTED]>:
> I'm sure you have the essence below, but I'm not familiar with the In/ Out
> notation. Apparently, I need to scoop up the In lines into a file and add
> some print stmts for the In[x] d lines.
Kent uses IPython, which is an enhanced version of the stand
2008/9/8 Wayne Watson <[EMAIL PROTECTED]>:
> def adjust_ftime(atime, sec):
> # mmdd_hhmmss, seconds in, new mmdd_hhmmss out
> ts = atime[1:-7] # use time stamp portion
> ayear = int(ts[0:4])
> amonth = int(ts[4:6])
> aday= int(ts[6:8])
> ahour = int(ts[
2008/9/5 Terry Carroll <[EMAIL PROTECTED]>:
> So here's my routine to address the problem. It consists of making a
> multiplication table of coefficients that includes the factor such as 5,
> 25, 125, etc., and their values (1, 6, 31, etc). Then, starting with the
> highest ones first, successiev
2008/9/2 Wayne Watson <[EMAIL PROTECTED]>:
> Is there some method or function that checks whether a date is valid. For
> example, these are not valid (/mm/dd format here for reference.):
[...]
> Perhaps a Try is useful with some function?
Yup. Have a look at time.strptime.
Don't be afraid to
2008/9/2 Wayne Watson <[EMAIL PROTECTED]>:
> How do I just get the current time? The following gives me 00:00:00.
>
> import datetime
>
> dt = datetime.time()
datetime.datetime.today() will give you "now" as a datetime. You can
then extract a time object from it:
>>> datetime.datetime.today()
da
2008/9/1 Richard Lovely <[EMAIL PROTECTED]>:
> Just a couple of quick questions:
> What differences are there in efficency (i.e. time and memory) between
> string concatenation ("foo" + "bar") and printf style formatting
> ("%s%s" % ("foo","bar")).
The timeit module may provide some insight:
Morp
2008/8/26 John Fouhy <[EMAIL PROTECTED]>:
> The hex() function (and oct() too) provides you with a different
> string representation from the default. If you want to change python
> to display integers in hex instead of decimal by default, I can't help
> you.. (well, maybe
2008/8/26 Py Hex <[EMAIL PROTECTED]>:
> When I run this:
>
type(hex(12))
>
>
> I get a string type back, i.e, '0xC' not 0xC
>
> On the other hand, if I use 0x with data, Python understands it is hex data
> and not a string value.
>
e = 0xCD
type(e)
>
>
> Why does the Hex builtin f
2008/8/19 dave selby <[EMAIL PROTECTED]>:
> Hi all,
>
> I am using the pwd lib where I am codeing things like ...
>
> gid = pwd.getpwnam(apache2_user)[3]
>
> where as I would like to code it as ...
>
> gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]
>
> but I get
>
> gid = pwd.getpwnam(apache2_user)[p
2008/8/14 Benjamin Serrato <[EMAIL PROTECTED]>:
> Are there any modules I should know about? Specifically How can I read/write
> from places.sqlite?
Here's some code to get you stared (requires python 2.5):
>>> import sqlite3
>>> db = sqlite3.connect('places.sqlite')
>>> c = db.cursor()
>>> c.exe
On 31/07/2008, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> I am populating a dictionary from an input file, and would like to create an
> error code if a string is sent to a variable that expects a float or int.
>
> INPUT = {}
> for line in open(infile):
> input_line = line.split(' = ')
> IN
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote:
> Your explanation is very help. It does make be wonder the usefulness
> of join with strings. Do you have a practical example/situation?
Kent's example is common: you might have a list of strings that you
want to display to the user, so you ca
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote:
> Good point. I guess I am surprised a little that Python does not error
> on that you cannot assign a variable to a module name. I know I need
> to learn proper coding techniques.
Well, that wouldn't really work because you don't know what o
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote:
> Hi tutor list,
>
> Just trying to add some clarity to the built-in function strings using
> join. The Python help
> screen says it returns a string which is a concatenation of strings in
> sequence. I am concatenating
> the string I am workin
On 30/07/2008, sai krishna <[EMAIL PROTECTED]> wrote:
> I wanted to print out all the combinations of a given word.
A thought for you:
Let's say you want to find permutations of the string 'abcd'. Some of
those permutations will start with 'a' -- how many? Can you list all
the permutations star
On 29/07/2008, Daniel Sarmiento <[EMAIL PROTECTED]> wrote:
> I tried to run your code and checked (with top) the memory ussage and
> it uses more than 2 Gb of memory.
>
> I tried to modify the code a little bit to use less memory and came up
> with this:
>
> fib = {0:0,1:1}
>
> even = []
>
>
On 25/07/2008, Sam Last Name <[EMAIL PROTECTED]> wrote:
>
> Okay thanks still didnt get it working but one step closer. Take a look at
> this
>
>
> a = input("What is the variable a?")
> b = input("What is the variable b?")
> c = input("What is the variable c?")
> print -b + [((b*b - 4*a*c)**0.5)/(
On 25/07/2008, Sam Last Name <[EMAIL PROTECTED]> wrote:
> Here wats i got so far. :) and also, is there a function for square root?
Have a look at the math module.
(you can also do fractional exponentiation.. remember, sqrt(x) is the
same as x**0.5)
--
John.
On 21/07/2008, Neven Goršić <[EMAIL PROTECTED]> wrote:
> >>> s='e:\mm tests\1. exp files\5.MOC-1012.exp'
> >>> os.path.split(s)
> ('e:\\', 'mm tests\x01. exp files\x05.MOC-1012.exp')
[...]
> The problem is that \1 and \5 is wrongly understood.
Yup, that's not surprising.
> I know that
> ever
On 18/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote:
> I see what you mean. I have tested it, and I have gotten a weird result:
>
> >>> def shorten(lst):
> ... lst = lst[:-1]
>
> ...
>
> >>> lista = [1,2,3,4]
> >>> shorten(lista)
> >>> print lista
> [1, 2, 3, 4]
[...]
> Strange...wh
On 18/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote:
> How come the stack doesn't shrink when I pop off the last value? I tested
> the code in the interpreter:
>
> >>> lista = [1,2,3,4]
> >>> lista[:len(lista)-1]
> [1, 2, 3]
> >>> lista = lista[:len(lista)-1]
> >>> lista
> [1, 2, 3
On 17/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Okay so i have a list of lists just as you describe below...I hate to make
> myself look really stupid...but I don't see how this converts to a tree
> structure...I was looking at this earlier and I guess what's confusing me
> are th
On 17/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Do you have any pointers on how to get from here
>
> continent = ["australia", "europe", "america", "asia"]
> country = [["spain", "germany", "belgium"], ["united states", "canada"]]
> state = ["california", "oregon", "arizona"]
>
>
On 17/07/2008, Terry Carroll <[EMAIL PROTECTED]> wrote:
> ps doesn't show memory usage as far as I can tell (that may be a cygwin
> thing; I see some references online that suggest it can in some
> environments). I don't have top or vmstat, but I'll look into those.
Hmm, yeah, cygwin ps seems q
On 16/07/2008, Michiel Overtoom <[EMAIL PROTECTED]> wrote:
> Lauren wrote...
> > Based on some research I've done, I think I want my data structure to
> > be a series of lists within lists:
> # start of example
>
> # this example uses a hierarchy of three levels: 1) continent, 2)
> country/st
On 10/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
> Sorry for this, most likely, idiotic question on my part. I'm really
> liking Python and it's
> ease of use. My only trouble is that I'm not sure how to use a script that
> I've saved, during
> another script located withi
On 10/07/2008, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 9, 2008 at 9:38 PM, John Fouhy <[EMAIL PROTECTED]> wrote:
> > Is the generator expression grammar right? How do I parse, e.g.,
> > '(x+1 for x in range(10))'? Seems like there's no
On 10/07/2008, Kent Johnson <[EMAIL PROTECTED]> wrote:
> The actual formal syntax definitions for the two are slightly different:
> http://docs.python.org/ref/lists.html
> http://docs.python.org/ref/genexpr.html
>
> Presumably this means there is something that is syntactically allowed
> in on
On 09/07/2008, Paul McGuire <[EMAIL PROTECTED]> wrote:
> > def length(self):
> > dx,dy = self.p1 - self.p2
> > return (dx**2 + dy **2) ** 0.5
>
> How about:
>
> def length(self):
> return math.hypot( *(self.p1 - self.p2) )
>
> Compiled C code will be much faster than squaring and
On 09/07/2008, bob gailer <[EMAIL PROTECTED]> wrote:
> or just [ x for x in LIST if x ]
or filter(None, LIST). But that's a bit obscure.
(fractionally faster, though, according to my brief experiment with timeit)
--
John.
___
Tutor maillist - Tuto
On 09/07/2008, Kelie <[EMAIL PROTECTED]> wrote:
> I think comtypes or pywin32 do take care of some conversion between Python
> types and VB types. But they don't work with AutoCAD.
Hi Kelie,
This is a short excerpt from _Python Programming on Win32_:
"""In many cases, PythonCOM can translate be
On 08/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote:
> Basically, if the two the x values are the same, I will get a
> ZeroDivisionError. A line in this
> case would simply point straight up. What would slope be in this case? I
> will admit that
> this is probably a math problem not a
On 08/07/2008, Kelie <[EMAIL PROTECTED]> wrote:
> I'm trying to translate the following VB code into Python and not sure how to
> create an array of variants.
I'm not sure what an array of variants in VB is -- perhaps an array
that can contain objects of any type?
> Python code
> import array
On 08/07/2008, David <[EMAIL PROTECTED]> wrote:
> Hi, I am trying to get a while loop that will execute 5 time then stop.
Hi David,
The standard pattern is like this:
i = 0
while i < 5:
# the stuff you want to do goes here
i = i + 1
Note that if you know exactly how many times you will
On 03/07/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "John Fouhy" <[EMAIL PROTECTED]> wrote
> > you can instead say:
> >
> > try:
> > foo()
> > except TypeError:
> > # do something else
> This makes slightly more sense,
On 03/07/2008, Emil <[EMAIL PROTECTED]> wrote:
> I have created a class called Fibs which allow you to access a specific
> number in the
> Fibonacci series(http://en.wikipedia.org/wiki/Fibonacci_number) But it seems
> to me that it
> is a bit inefficient, any suggestions on how to make it more e
1 - 100 of 503 matches
Mail list logo