Re: [Tutor] Fwd: RE: Fwd: Re: Sklearn

2017-03-11 Thread Matt Williams
Having done similar, the options are (depending on the dataset):

1: Python to read, clean and classify data, then R to do the analysis (e.g.
regression analysis)

2: Python to read, clean and classify data, and python for the analysis

3: All in R

If you want to use Python for the analysis, most people would probably use
Pandas for the data cleaning and SciPy for the stats. However, there are
alternatives.

There is a tutorial that describes almost exactly the same problem as yours
here, using Pandas and some other packages:

http://blog.yhat.com/posts/logistic-regression-and-python.html

HTH,
Matt


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Created Function, Need Argument to be a String

2016-12-17 Thread Matt Williams
Use the str() function.

M

On Thu, 15 Dec 2016, 07:56 Bryon Adams,  wrote:

> Is there a way to force my argument to always be a string before
> entering the function? Else, is there a better way to go about this? In
> whatever program I write, I could change what I want as input to be a
> string prior to tossing it into the function but I think it would make
> more sense for my function to already do it. The function otherwise
> works. This is on Python3.5 under Fedora 25
>
> The only other thing I could think of would be to put exceptions in for
> syntax error and whatever else pops up as I go along, though to be
> honest it *should* always be a string that gets dumped into the
> function. Not sure how I'd put the exception together though since it's
> not making it into the function prior to failing.
>
> ---
> Error from interpreter: (looks like it's taking issue with it being a
> number it doesn't know how to deal with)
>
>  >>> ip_checker(169.254.0.1)
>File "", line 1
>  ip_checker(169.254.0.1)
> ^
> SyntaxError: invalid syntax
>
> ---
> My function:
>
> def ip_checker(ip_address):
>'''
>Takes one IP address and checks whether it is valid or not.
>'''
># Try to convert to integers
>try:
>  ip_addr = [int(i) for i in ip_address.split('.')]
>except ValueError:
>  print('Invalid characters were entered or an octet is empty, please
> try again.')
>  return False
>
># Determine how many octets were entered
>if len(ip_addr) != 4:
>  print('Incorrect number of octets, please try again.')
>  return False
>
># Determine validity of first octet
>if ((ip_addr[0] > 223) and (ip_addr[0] < 256)) or (ip_addr[0] == 0):
>  print('First octet is reserved or zero.')
>  return False
>
># Determine if this is a loopback address
>if ip_addr[0] == 127:
>  print('I think that was a loopback address, please try again.')
>  return False
>
># Determine if this is an APIPA address
>if (ip_addr[0] == 169) and (ip_addr[1] == 254):
>  print('I think that was an APIPA address, please try again.')
>  return False
>
># Determine if the last three octets are between 0-255
>for octet in (ip_addr[1], ip_addr[2], ip_addr[3]):
>  if octet not in [i for i in range(0,256)]:
>print('Octet too large or too small, please try again.')
>return False
>  else:
>print('The IP address {} is valid.'.format(ip_address))
>return True
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Advice on multi-dimensional data storage

2016-03-16 Thread Matt Williams
Dear Tutors,

I am looking for some advice. I have some data that has three dimensions to
it. I would like to store it such that one could manipulate (query/ update/
etc.) by dimension - so it would be feasible to ask for all of the data
that shares a value in d1, or iterate over all of the values via d2.

I found some answers on StackOverflow which I need to have a longer look
at, but I would be grateful for any thoughts.

Thanks,
Matt
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Citing Python

2016-03-15 Thread Matt Williams


No, but in his defence, I can imagine someone reading the dissertation 
and asking for a citation..


(Apologies for TP).

M
On 15/03/2016 18:43, Alan Gauld wrote:

On 15/03/16 11:45, Holderness, Ellie wrote:


How do I cite Python for my dissertation bibliography?
I used version 3.5.1.

I'm not sure a citation is strictly necessary for a programming
language, but if you want to you could cite the Python web site.
Would you cite JavaScript, CSS or HTML if you built a website?
Or SQL if you built a database?

If you used a particular tutorial to learn the language
you could cite that (either as a book or web site).

HTH


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Recommendations for best tool to write/run Python

2016-03-02 Thread Matt Williams
Can someone recommend an open-source editor for all 3 platforms?

M

On Wed, 2 Mar 2016 21:37 Ben Finney,  wrote:

> Ben Finney  writes:
>
> > Short of [the heavyweights Vim and Emacs], I'd still recommend a
> > community-owned, free-software, highly flexible programmer's editor.
> > If you're on GNU+Linux, use the Kate or GEdit editors; they integrate
> > very nicely with the default desktop environment and are
> > well-maintained broadly applicable text editors. GEdit in particular
> > has good Python support.
>
> In particular, when teaching students, please steer them away from
> proprietary software, regardless of price.
>
> Non-free software such as Sublime Text, PyCharms, Wing IDE, and the
> like, sometimes have a zero-dollar license, but your students should not
> be encouraged to use tools they are forbidden to learn about and share.
>
> In education, please use free-software tools – that is, software with
> license to inspect, modify, and share the changes – so your students can
> learn at any level their interest takes them.
>
> --
>  \   “What I resent is that the range of your vision should be the |
>   `\ limit of my action.” —Henry James |
> _o__)  |
> Ben Finney
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Recommendations for best tool to write/run Python

2016-03-02 Thread Matt Williams
I teach an introductory programming course to medical students (and a few
doctors).

I would look at Sublime Text 2 if one Windows/ Mac. Has a 'nag' screen to
remind you to buy, but feels simple enough when you start it.

M

On Wed, 2 Mar 2016 19:50 Ben Finney,  wrote:

> Lisa Hasler Waters  writes:
>
> > Ben, in terms of time for learning curve, I suppose we do have some
> > limitations as we are up against school schedules. However, if it is
> > something I could learn in a reasonable time that I could then more
> > quickly walk my students through then I'd be up for the challenge!
>
> In that case, my recommendation is to learn a good programmer's editor,
> and let your students gain exposure to that.
>
> Emacs and Vim are the unchallenged masters here; community-owned,
> free-software, cross-platform, mature and highly flexible with support
> for a huge range of editing tasks. Learning either of those will reward
> the student with a tool they can use broadly throughout whatever
> computing career they choose.
>
> They aren't a small investment, though. That “mature” comes at the cost
> of an entire ecosystem that evolved in decades past; concepts and
> commands are idiosynratic in each of them. It is highly profitable for
> any programmer to learn at least one of Emacs or Vim to competence, but
> it may be too much to confront a middle-school student in limited class
> time. Maybe let the class know they exist, at least.
>
> Short of those, I'd still recommend a community-owned, free-software,
> highly flexible programmer's editor. If you're on GNU+Linux, use the
> Kate or GEdit editors; they integrate very nicely with the default
> desktop environment and are well-maintained broadly applicable text
> editors. GEdit in particular has good Python support.
>
> I would recommend staying away from any language-specific IDE. Teaching
> its idiosyncracies will still be a large time investment, but will not
> be worth it IMO because the tool is so limited in scope. Better to teach
> a powerfuly general-purpose programmer's editor, and use the operating
> system's facilities for managing files and processes.
>
> --
>  \“Humanity has advanced, when it has advanced, not because it |
>   `\ has been sober, responsible, and cautious, but because it has |
> _o__)been playful, rebellious, and immature.” —Tom Robbins |
> Ben Finney
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-04 Thread Matt Williams
Just as a note - you are not the only person caught out by this - it is a
very common slip.

I wonder whether it would be worth adding a more explicit line about this
in the Python Docs?

Matt

On Wed, 3 Feb 2016 16:13 Ek Esawi  wrote:

> Hi All
>
>
>
>
>
> I have a code that reads a csv file via DictReader. I ran into a peculiar
> problem. The python interpreter ignores the 2nd code. That is if I put the
> reader iterator 1st, like the code below, the enumerate code is ignored; if
> I put the enumerate code 1st, the reader code is ignored. I am curious to
> know the nature of such behavior. EKE
>
>
>
> Here  part of my code:
>
>
>
> .
>
> .
>
> .
>
> reader = csv.DictReader(MyFile)
>
> for row in reader:
>
> list_values = list(row.values())
>
> print (list_values)
>
>
>
> for i,j in enumerate(reader):
>
> print(j)
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

2016-01-28 Thread Matt Williams
This is a problem I have come up against often, and I don't think I have a
good answer, so if anyone else does, I would be glad to hear it!

I would be tempted to generate a 'test data.CSV" file, and run the tests on
that. It means that as you write the code, and find some edge cases, you
can alter your code and add the edge cases to the test data. That way, the
test data acts to cover the space of various oddities in your work.

I would be very keen to hear other ideas,

BW,
Matt

On Thu, 28 Jan 2016 20:12 Danny Yoo  wrote:

> On Thu, Jan 28, 2016 at 12:44 AM, Alan Gauld 
> wrote:
> > On 28/01/16 04:23, boB Stepp wrote:
> >
> >> I don't want to mess with what will become the program's *real*
> >> classifiers.txt (And other needed text files to come, that will
> >> likewise be editable.), so how do I simulate these various needed file
> >> operations in a way that tests the actual program code, but without
> >> touching the actual data files?
> >
> > Danny has shown you one way using a mocked filesystem.
> > But for your case can't you just specify a file location
> > as an environment variable or argv? That way you get the
> > advantage of using real files, which can be an important
> > factor in timing issues, especially if you plan on having
> > any concurrency going on. And it's simple to do...
>
>
> Just to emphasize what I think is an essential point: the basic
> approach we're doing is here parameterization: to take something that
> used to be hardcoded, and turn it into a parameter that allows us to
> substitute with something else.
>
> As Alan says, you can also parameterize in a different way: by the
> directory location where files are being read.  Then you can use a
> temporary directory for your unit tests, and prepare the testing
> environment that way.  If you take this approach, the tempfile module
> can help with this.
>
> https://docs.python.org/3.5/library/tempfile.html
>
> https://docs.python.org/3.5/library/tempfile.html#tempfile.TemporaryDirectory
>
>
> The mocking approach is one where we're doing this parameterization at
> a behavioral level.  When we started to program, we may have initially
> thought that a parameter could only be numbers, since that's what
> algebra traditionally uses as its domain.  When we program, we find
> that domain of values expanded to a richer set, and not just to
> inactive values like strings or dictionaries or images, but now we can
> pass entire collections of behavior as a parameter.  That's one of the
> lessons of OOP: values are not just inert data: they can define
> dynamic behavior.
>
> (Aside: this is somewhat why I think the topic of inheritance and
> inheritance hierarchies are entirely the wrong things to focus on when
> we're teaching OOP.  Those topics are often used as a shortcut
> mechanism to do code sharing, and although that's convenient, my
> opinion is that it misses the forest for the trees.  What I think
> OOP's heart is beating is in the ability to parameterize behavior.)
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python help

2015-07-06 Thread Matt Williams
Personally I would start with Python 2.7, and start with simple scripts.

The standard library in Python is very wide, and having a good
understanding of what is already there is very useful.

As to GUI/ Web/ etc. - I think it depends on what you want to do. However,
you will need the basics before then.

You don't say what your background is, but if you've done some programming
before then the basics should be pretty quick.

Once you've done the basics, some more intermediate level stuff is
useful. Personally, I find reading source code useful (there is a tonne on
the PPI). There are some other resources listed here:

https://news.ycombinator.com/item?id=5998750

HTH,
M

On 6 July 2015 at 15:24, Cary Developer carydevelo...@gmail.com wrote:

 I am looking for help on getting started with Python.  This link says it
 all:



 http://raleigh.craigslist.org/cpg/5108772711.html



 Any help (and response to the CL post) would be truly appreciated.  Thanks.



 -Roger



 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] newb help reading lines from csv

2012-10-26 Thread Matt Williams

Dear Rob,

This caught me out as well for a long time.

As I understand it, csv.reader is a file-reader, which iterates ONCE 
over the file. There may be more elegant solutions, but I do:


import csv
ifile = open('test.csv', r)
reader = csv.reader(ifile)
inData = []
for row in reader:
inData.append[row]  
ifile.close()

you can now loop through inData to your heart's desire.

HTH,

Matt
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] extract specific column

2011-10-12 Thread Matt Williams

On 12/10/2011 18:21, Anna Olofsson wrote:

Hi,

I'm a beginner at python and I'm trying to extract a specific column 
from a txt file ( see attached file).


In the attached file I want to extract the entire column/pph2_prob 
/(i.e. column 16). But I want to get all the values from that column 
without the headline /pph2_prob.


/How do I accomplish that?

Best,
Anna




Dear Anna,

Using the CSV module should work.

Something along the lines of (untested):

inLines = CSV.DictReader(/path/to/myfile.csv)
data = []
for a in inLines:
data.append(a)

for line in data:
print line[/pph2_prob/]


Once you've got that working you just need to put the results in a file, 
instead of printing them.


On a practical note (and there may be many reasons why not to), it might 
be easier to open in a spreadsheet and take the data from there


HTH,

Matt
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Merging Text Files

2010-10-13 Thread Matt Williams

Dear Ara,

I have been working on something similar.

In the end I used a dictionary for each line in the file, and stored 
data from each file in a different set. I then matched using one (or 
more) element from each dictionary. This is really very close doing a 
join in a database, though, and if I had more time you might want to 
explore that route (csv - sqlite, manipulate using sqlobject/ 
sqlalchemy/ django/ etc.)
the csv module has some good facilities for reading/ writing csv files. 
However, as yet I don't think it, or csvutilities, lets you do the sort 
of merging you say.


HTH,

Matt

Robert Jackiewicz wrote:

On Wed, 13 Oct 2010 14:16:21 -0600, Ara Kooser wrote:

  

Hello all,

  I am working on merging two text files with fields separated by
  commas.
The files are in this format:

File ONE:
*Species, Protein ID, E value, Length* Streptomyces sp. AA4,
ZP_05482482, 2.82936001e-140, 5256, Streptomyces sp. AA4,
ZP_05482482, 8.03332997e-138, 5256, Streptomyces sp. AA4,
ZP_05482482, 1.08889e-124, 5256, Streptomyces sp. AA4, ZP_07281899,
2.92539001e-140, 5260,

File TWO:
*Protein ID, Locus Tag, Start/Stop*
ZP_05482482, StAA4_010100030484,
complement(NZ_ACEV0178.1:25146..40916) ZP_07281899, SSMG_05939,
complement(NZ_GG657746.1:6565974..6581756)

I looked around for other posts about merging text files and I have this
program:
one = open(final.txt,'r')
two = open(final_gen.txt,'r')

merge = open(merged.txt,'w')
merge.write(Species,  Locus_Tag,  E_value,  Length, Start/Stop\n)

for line in one:
 print(line.rstrip() + two.readline().strip())
 merge.write(str([line.rstrip() + two.readline().strip()]))
 merge.write(\n)
merge.close()

inc = file(merged.txt,r)
outc = open(final_merge.txt,w)
for line in inc:
line = line.replace('[','')
line = line.replace(']','')
line = line.replace('{','')
line = line.replace('}','')
outc.write(line)

inc.close()
outc.close()
one.close()
two.close()

This does merge the files.
Streptomyces sp. AA4, ZP_05482482, 2.82936001e-140,
5256,ZP_05482482, StAA4_010100030484,
complement(NZ_ACEV0178.1:25146..40916) Streptomyces sp. AA4,
ZP_05482482, 8.03332997e-138, 5256,ZP_05477599,
StAA4_01015861, NZ_ACEV0113.1:86730..102047

But file one has multiple instances of the same Protein ID such as
ZP_05482482. So the data doesn't line up anymore.  I would like the
program to search for each Protein ID number and write the entry from
file 2 in each place and then move on to the next ID number.

Example of desired output:
Streptomyces sp. AA4, ZP_05482482, StAA4_010100030484,
2.82936001e-140, 5256,
complement(NZ_ACEV0178.1:25146..40916) Streptomyces sp. AA4,
ZP_05482482, StAA4_010100030484, 8.03332997e-138, 5256,
complement(NZ_ACEV0178.1:25146..40916)

I was thinking about writing the text files into a dictionary and then
searching for each ID and then insert the content from file TWO into
where the IDs match. But I am not sure how to start. Is there a more
pythony way to go about doing this?

Thank you for your time and help.

Regards,
Ara



Why don't you try using the csv library which is part of the standard 
python library to parse you files.  It allows simple and efficient 
manipulation of comma separated value files.


-Rob Jackiewicz

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
  


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Lexicographic ordering (or something simpler)

2007-03-13 Thread Matt Williams
Dear All,

I'm trying to write something to calculate rule priorities, based on 
their provenance (ultimately I'm after a lexicographic ordering)

I have a set of terms (the provenances) I'm try to sort. I've done it by 
associating each possible set of terms with a dictionary, and then using 
the elements of the set as keys of the dictionary, so that it can look 
up the values. This is (almost certainly) sub-optimal, but ok for now

Where I get stuck is that each rule is compared pairwise to each other; 
the precedence of the set of rules is then based on that. Since there 
can be ties between the rules, the result of each pairwise comparison 
for two rules a  ) is either 1,0 or -1, where 1 == a beats b, -1 == b 
beats a and 0 == tie.

At the moment I get back a list of results from testing one set of rules 
against the other. I now need to make a decision based on all the 
results. I've tried coding it as if...elif statements, but that all gets 
horrible.

Given a list of the form [1,0,0,1,-1] I need to make decision (in this, 
  it is undecided, so we drop down to the next criteria).

Any ideas/ pointers as to how I implement this?

Thanks,

Matt


-- 
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Sorting a list in an add order

2006-09-06 Thread Matt Williams
Dear List,

I've written a small script to extract the definitions from my thesis, 
and output them as a .tex file, which works ok but I have a small problem.

The input is done by specifying a directory, and using glob to find the 
.tex filenames.

However, I want to process them so that they are arranged in the correct 
order, which means I need to sort the list of files. Of course, because 
they aren't named in any (obvious) order, I'm a bit stuck.

I thought about using a dictionary to map names and order: so {OAF:1, 
Valuation:2...etc}, but I don't don't know how to take it on from 
here. I was thinking of looking up the filename in the dictionary (using 
.startswith() to get some basic rough-matching capacity) and then using 
that to return the order that the files should be handled in.

Any comments/ better ideas?

Thanks,

Matt
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Regex

2006-08-14 Thread Matt Williams
Dear All,

I know this has come up loads of times before, but I'm stuck with what 
should be a simple Regex problem. I'm trying to pull all the definitions 
  from a latex document. these are marked

\begin{defn}
TEXT
\end{defn}

so I thought I'd write something like this:

filename = '/home/acl_home/PhD/CurrentPhD/extensions1_14.8.6.tex'

infile = open(filename,'r')

def_start = \\begin\{defn\}
def_end = \end{defn}

def_start_reg = re.compile(def_start)

l = 0
while l  500:
 line = infile.readline()
 #print l, line
 res = re.search(def_start_reg,line)
 print l, res
 l = l+1

but it doesn't return any matches (BTW, I know there's a defn tag in 
that section). I thought it was my regex matching, but I checked it with 
an online checker, and also with a small bit of text:


def_start = \\begin\{defn\}

def_start_reg = re.compile(def_start)

text = atom that is grounded. These formulae are useful not only for the
work on valuation but are also used in later chapters.

\begin{defn}
A Patient-ground formula is a formula which contains a grounding of
$Patient(x)$. The other atoms in the formula may be either ground
or non-ground.
\end{defn}
Having defined our patient ground formulae, we can now use formulae
of this form to define our patient values.

res = re.search(def_start_reg, text)
print res



and this returns a MatchObject. I'm not sure why there should be any 
difference between the two - but I'm sure it's very simple.

Thanks for any tips,

Matt
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (*args, **kwargs)

2006-08-04 Thread Matt Williams
Dear All,

I have learnt to do bits of python, but one of the things I cannot get 
my head around is the *args, **kwargs syntax.

I have tried reading stuff on the web, and I have a copy of the python 
cookbook (which uses it as a recipe early on) but I still don't 
understand it.

Please could someone explain _very_ slowly?

Apologies for the gross stupidity,

Matt


-- 
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (*args, **kwargs)

2006-08-04 Thread Matt Williams
Dear Etienne  Carlos,

Thanks so much for that - much clearer!

I guess the next question is _how_ do you use it intelligently? I'm 
interested because I'm trying to put stuff into a db using sqlobject.

Obviously one way would be:

class MyClass:

 def __init__(self,**kw)
 self.property1 = self.kw['property1']
self.property2 = self.kw['property2']
etc

Does anyone know of an example of this ?

Thanks,

Matt
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python DB

2006-02-07 Thread Matt Williams
You might also want to have a look at DABO; I don't know how well it 
work on a handheld, though.

http://dabodev.com/about

Matt
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python on Fedora

2006-01-24 Thread Matt Williams
FC4 (the latest finished one) has python 2.4.1 as part of the distro (I
think RedHat actually use python for some of their scripts).

Just pull up a terminal and type 'python' and you should get the
prompt...

If you _are_ running FC4 and have more probs, feel free to drop me a
line. at matt at mwilliams.org and I can try and help (since I am sat in
front of an FC4 machine).

WRT EMACS, I've never tried to get it going I use Eclipse and PyDev,
or else SPE is worth a look.

HTH,

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Favourite Modules - wiki

2005-11-15 Thread Matt Williams
I think the Wiki's a great idea.


del.icio.us already has a Python tagged page: http://del.icio.us/tag/python

Other pages I use are:

http://mechanicalcat.net/pyblagg.html

http://www.planetpython.org/

I've added a couple of things to the Wiki - SQLObject and RSPython

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] TurboGears - and some issues

2005-11-14 Thread Matt Williams
Dear Alan,

I haven't used it, but I've looked through it, and it looks v.
interesting. One of the things I like is that it glues lots of different
bits together (I came across it while looking at SQLObject), and so
benefits from their advances.

This bit is meant as a complimentI was a bit surprised that you hadn't
come across it before, as in general you seem to be one of the core team
on the list (in that you tend to answer rather than ask most questions).

This got me thinking about how we stay up with different, and new,
python projects. I tend to look at the Daily Python URL, as well as some
Technorati and del.icio.us tagged sites/blogs. Where else do other
people look?

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Symbolic maths In Python

2005-11-13 Thread Matt Williams
I don't know if this will do anywhere near what you want...

http://swiginac.berlios.de/

is a set of Python bindings to GiNaC, which handles symbolic maths in
C/C++.

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Latin Perl

2005-11-10 Thread Matt Williams
The suprising thing about Latin Perl is that it's more
readable than normal Perl

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python and Semantic Web

2005-11-08 Thread Matt Williams
Mea Culpa, Mea Culpa, Mea Maxima Culpa (or, MCMCMMC to repeat my sin of
poly-acronymony.

Semantic Web - (loosely) the idea of incorporating semantic information
in the WWW, so it becomes machine understandable (rather than just
parsable).

CWM is Tim Berners-Lee's (and others) tool to handle ontologies. I think
it has some rules in-built, but for reasons of efficiency, most ontology
tools communicte with external Description Logic Reasoners via the DIG
(Desc. Logic Implementation Group) interface, which is http/XML based.

Much of the semweb stuff is OWL (Web Ontology Language - need to be a
Winnie The Pooh fan to get the acronym) based. OWL is a layer that lies
on top of RDF (which in turn, lies on top of XML). In general, yu build
an ontology in OWL, and then interface with a reasoner to infer more
info. about the model.

The two big ontology building tools are Protege (with the Protege OWL
plugin) and SWOOP, but both are Java based.

HTH.
Matt


-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Easier way to access wxPython

2005-11-07 Thread Matt Williams
Dear All,

Just a note: When the next question about which GUI for Python comes
around (and I should plead guilty to having asked a few times) I thought
that the Dabo framework, which wraps wxPython in a nicer API would be
worth pointing to.

And even if the question didn't get asked, I thought people might like
to know...

http://daboenv.com/

HTH,
Matt

-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Mono

2005-11-07 Thread Matt Williams
Dear List,

Slightly off topic, but could someone explain/ point me to a URL that
explains how one might use Python with Mono (I guess it would be
IronPython, rather than CPython), and what advantages it might give you
(apart from a possible speed up of IronPython vs. CPython). I'm
especially interested in the idea of being able to write different bits
in different languages, and then run them all on Mono.

Thanks,
Matt
-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Nokia 60 series

2005-10-29 Thread Matt Williams
There's some extra info here:

http://comments.gmane.org/gmane.comp.python.announce/5658

HTH,
Matt
-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570
http://acl.icnet.uk/~mw
http://adhominem.blogspot.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] General programming questions

2005-10-27 Thread Matt Williams
Dear List,

I've got a few general programming (not really specific to python,
although you're all so helpful, I thought I'd ask here). I understand
some of these are a bit long, so if you could just point me to some
resources, I'd be very grateful.

1: I need to create objects that have variable levels of behaviour
(controlled perhaps by a .config file). I can do the file reading, etc.
- but how do I implement the behaviour, apart from just re-writing all
the functions for each config level?

2: I need to implement polmorphism in some methods (and a constructor).
At the moment, I have something like:

def __init__ (self, a, b, c):
if type(a) == type(a)
then.
elif type(a) == type([a])
then

I'm sure there must be a better way to do this (both the polymorphism
and the type testing) - but I don't know how to do it.

Thanks a lot,

Matt

-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow
Cancer Research UK
+44 (0)207 269 2953
+44 (0)7384 899570

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 20, Issue 26: New Python Book

2005-10-08 Thread Matt Williams
IMHO, as regards the book using wxPython, rather than Tkinter: 
I've failed to get Tkinter to compile on several installs, 
whereas I can usually get wxPython to work. Also, wx seems 
to be better documented.I know it's not ideal to pick one
platform, but I would guess that wx would be a reasonable default.

Matt



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Accessing Variables

2005-10-05 Thread Matt Williams
Dear List,

I'm trying to clarify something about accessing variables.

If I have ONE.py file with some variable a, and ONE imports TWO, which
has a variable b, can TWO access variable a (I don't think so, but I
just thought I'd check).

I guess the way round this is just to make some classes  objects, and
then they can easily pass parameters to each other, but I just thought
I'd check.

Matt  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python DB

2005-09-22 Thread Matt Williams
Dear List,

Thanks for all the advice! Obviously, I'm still a bit torn, but some of
the ideas looked good.

In terms of spec, the DB can be fairly simple (single access, etc.).
Lower dependency on other libraries is good. Also, it needs to be cross-
platform.

The problem (I have) with SQL-type DB is that I cannot be sure ahead of
time of the exact data structure. The DB will be about patients, who
have diseases, and also have treatments.Clearly, I can't specify now
the exact structure of the table. The advantage of SQL is that you can
(in general) do things like constrain types for fields, and give
enumerated options, which makes the data more consistent.

The thing I liked about KirbyBase was that it used text files. This is a
real advantage, as it means that I can access the data from other
application easily, and also makes it easier to back-up (can just copy a
few files). The same would seem to be true of the XML-based options. The
advantage of ZODB was that the object structure seemed to map well to
the concept of patients, with diseases, with treatments, etc. (and
Shelve would work at least as a trial implementation)

The final thing is that I needs to have a simple GUI frontend. The nice
thing about ZODB is that I could just map the eventhandlers to functions
on objects..

If people have more comments in the light of the bigger spec. above, I'd
still love to hear them...

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDEs

2005-09-14 Thread Matt Williams
I've used both PyDev and Wing IDE.

PyDev seems good, and is getting better. 
Wing is pay-for (although only $40 or so), but can be trialled. I thought
it was good, but had a huge problem trying to get it to play with a C library
I was using...

I've never managed to get Boa-Constructor to run...

As regards using wxPython - I thought it was ok, but frankly Glade was s
much easier..

(all IMHO)

Matt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python FTP GUI - Possible project ?

2005-08-01 Thread Matt Williams
Dear List,

Does anyone know of a Python FTP GUI tool ? Preferably based around
pyGTK+ ?

I've had a look (Google, vaults of Parnassus, etc.) but haven't found
one.

If there isn't one, then would people consider it a useful project for
newbie programmers (like myself). There have often been questions along
the lines of Where can I find projects to get involved in, and I
thought this might help.

Thanks,

Matt


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Filtering a String

2005-03-20 Thread Matt Williams
Dear List,

I'm trying to filter a file, to get rid of some characters I don't want
in it.

I've got the Python Cookbook, which handily seems to do what I want,
but:

a) doesn't quite and 
b) I don't understand it

I'm trying to use the string.maketrans() and string.translate(). From
what I've read (in the book and the Python Docs), I need to make a
translation table, (using maketrans) and then pass the table, plus and
optional set of characters to be deleted, to the translate() function.

I've tried:

#!/usr/bin/python
import string 
test=1,2,3,bob,%,)
allchar=string.maketrans('','')
#This aiming to delete the % and ):
x=''.translate(test,allchar,%,))

but get:
TypeError: translate expected at most 2 arguments, got 3

Please could someone explain this to me (slowly).
As a measure of my slowness:
This is my first programming language
I couldn't get the tutor list to work for ages - until I realised I was
sending all the desperate pleas for help to tutor-request. Perhaps there
is no hope..

Matt Williams


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Database

2005-02-11 Thread Matt Williams
I would recommend KirbyBase as a quick starter - it's nice and simple,
and outputs text files, so you can always check things manually.

http://www.netpromi.com/kirbybase.html

Matt 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Nifty

2004-12-17 Thread Matt Williams
I'd be interested,

Matt
On Fri, 2004-12-17 at 11:01, [EMAIL PROTECTED] wrote:
 Send Tutor mailing list submissions to
   [EMAIL PROTECTED]
 
 To subscribe or unsubscribe via the World Wide Web, visit
   http://mail.python.org/mailman/listinfo/tutor
 or, via email, send a message with subject or body 'help' to
   [EMAIL PROTECTED]
 
 You can reach the person managing the list at
   [EMAIL PROTECTED]
 
 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Tutor digest...
 
 
 Today's Topics:
 
1. suggestion for group project (Brian van den Broek)
 
 
 --
 
 Message: 1
 Date: Fri, 17 Dec 2004 05:12:40 -0500
 From: Brian van den Broek [EMAIL PROTECTED]
 Subject: [Tutor] suggestion for group project
 To: Tutor [EMAIL PROTECTED]
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 Hi all,
 
 A while ago, in a response:
 
 Danny Yoo said unto the world upon 2004-11-29 17:14:
  
  I just got in contact with Nick Parlante of the Nifty Assignments
  project; he's been collecting material on fun projects:
  
  http://nifty.stanford.edu/
  
  The projects there look pretty nice.  In fact, I'm thinking of
  adapting material on that page for us here on Python-Tutor.
  
  Is there a particular project that sounds interesting to folks? 
  Personally, I'm interested in:
  
  http://nifty.stanford.edu/catandmouse/html/
  
  But that's only because I helped tutor it back when I was at
  Berkeley's Self-Paced Center...  *grin* But if people want, I'd be
  happy to convert Professor Clancy's support code from C++ to Python.
 
 
 I've got a suggestion: would there be any interest among list members in 
 picking one of the assignments, working on it, and then doing a code 
 comparison/critique?
 
 When Danny posted, I did http://nifty.stanford.edu/2003/randomwriter/. 
 I thought about posting what I had done to the list and inviting such 
 comment/criticism, but was dissuaded by two things: 1) once I'd got my 
 code to a reasonable polish, with docstrings and all, it seemed a bit 
 long to just plunk onto the list, and, 2) I suspect much of the 
 interest, fun, and learning might well emerge from having a go at the 
 task and then seeing what others came up with. If I posted mine 
 unannounced, others wouldn't have the chance to go at the problem fresh.
 
 What do others think?
 
 I wonder if the length of code, the possible undesirability of a bunch 
 of answers to a collection of homework problems getting posted, and 
 other considerations might make this better as an off-list endeavour. 
 I'd be interested in doing it either here or on private channels. (If 
 there was interest and we opt for private, I could probably get my uni 
 to let me set up an unarchived listserv for the purpose.)
 
 Best to all,
 
 Brian vdB
 
 
 
 --
 
 ___
 Tutor maillist  -  [EMAIL PROTECTED]
 http://mail.python.org/mailman/listinfo/tutor
 
 
 End of Tutor Digest, Vol 10, Issue 72
 *

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to find complex roots

2004-12-09 Thread Matt Williams
Dick Mores wrote:
snip
My trusty $10 Casio calculator tells me that the 3 cube roots of 1 are:
1, (-.5 +0.866025403j), and (-.5 -0.866025403j), or thereabouts. Is
there 
a way to do this in Python?

snip

I think the neatest approach might be to consider that the n-complex
roots form at equal angle around the origin on an Argand diagram
(basically a cartesian plane) - here the points (in standard)
cartesian notation are at (1,0), (-0.5, 0.86) and (-0.5, -0.86). The
whole effect looks a bit like a Mercedes-Benz symbol rotated clockwise
by 90 degrees. The points, in this case, lie on the unit circle.

As a result, I think you could just divide 360 by n (for the n-roots),
set the 1st root at (1,0) and then position the others around the
circle, incrementing by the required number of degrees.

If I've remembered correctly, for c where |c| 1, the argument is the
same, but you need to take the nth root of the absolute value of c (this
can be ignored when we're doing it for 1, as of course the nth root of 1
is 1).

Obviously I haven't included any codebut I hope this helps a bit.

Matt

P.S. Thrilled to be able to answer something on the tutor list, instead
of just asking dumb questions!
-- 
Dr. M. Williams MRCP(UK)
Clinical Research Fellow,Cancer Research UK
+44 (0)207 269 2953
+44 (0)7834 899570

The views, opinions and judgements expressed in this message are solely those 
of the author.
The message may not have been reviewed or approved by Cancer Research UK

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Complex roots

2004-12-09 Thread Matt Williams
Further to my previous post, please find some code below:

Hope this helps,
Matt

#Complex number Roots
#Matt Williams 9.12.04

import math

number=complex(0.5,0)
n=float(3)

size=math.sqrt((number.real**2)+(number.imag**2))


arg=math.radians(360/n)

root=1/n

modulus=size**root

theta=float(0)
roots={}
i=0
while in:
y=round(modulus*(math.sin(theta)),3)
x=round(modulus*(math.cos(theta)),3)
roots[i]=(x,y)
theta=theta+arg
i=i+1

print roots

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor