Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread questions anon
excellent thank you for the warning, I will look into dictionaries alot more carefully now. I have some simple questions that I would like to ask straight away but will try and figure a few things out on my own first. Thanks again!! On Wed, May 9, 2012 at 11:16 AM, Andre' Walker-Loud wrote: > de

Re: [Tutor] List Indexing Issue

2012-05-08 Thread Jerry Hill
On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis wrote: > Hello python community, > > I'm having a small issue with list indexing. I am extracting certain > information from a PDB (protein information) file and need certain fields of > the file to be copied into a list. The entries look like this:

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread Andre' Walker-Loud
dear anonymous questioner, > Excellent, thank you so much. I don't understand all the steps at this stage > so I will need some time to go through it carefully but it works perfectly. > Thanks again! words of caution - you will notice that the way I constructed the data file - I assumed what th

Re: [Tutor] Sorting the Parts of a Dictionary into a List

2012-05-08 Thread Brian van den Broek
On 8 May 2012 23:23, Jacob Bender wrote: > Dear Tutors, > > My original email was this: > > "Dear tutors, > > I'm trying to create a neural network program. Each neuron is in a > dictionary and each of its connections and their strengths are in a nested > dictionary. So {0:{1:4, 2:5}}, 1:{0:6}, 2:

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread questions anon
Excellent, thank you so much. I don't understand all the steps at this stage so I will need some time to go through it carefully but it works perfectly. Thanks again! On Tue, May 8, 2012 at 4:41 PM, Andre' Walker-Loud wrote: > Hello anonymous questioner, > > first comment - you may want to look i

Re: [Tutor] Console Application - Key Events

2012-05-08 Thread BRAGA, Bruno
Yeah, what you say makes sense... I was hoping that there was a nice way of doing it, but I will just have to stick with "running the command yourself". I thought there could be a solution, maybe based on Ncurses, or even on the "read" command, but they can not get the keys pressed if the applicat

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread Rogelio
On Tue, May 8, 2012 at 11:06 AM, David Abbott wrote: > I have used this before; > > def uptime_report(): >    """Generate uptime""" >    p = subprocess.Popen("uptime > /tmp/uptime.txt", >            shell=True, stdout=subprocess.PIPE) >    return p.stdout.readlines() > > That was from python 2.6

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread Emile van Sebille
On 5/8/2012 3:14 PM Alan Gauld said... On 08/05/12 19:42, Emile van Sebille wrote: >>> from types import * >>> def test():pass ... >>> function=FunctionType >>> print isinstance(test,function) Wow, thanks for that. I knew about all the different function types in there but hadn't realised tha

Re: [Tutor] Sorting the Parts of a Dictionary into a List

2012-05-08 Thread Dave Angel
On 05/08/2012 05:23 PM, Jacob Bender wrote: > > > > def smartest(self): #Return the neurons in order from smartest to > dumbest in list form. > for neuron in self.neurons: > sorted(neuron, key=self.total(neuron)) > > The total function works when it returns the strength of

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread Alan Gauld
On 08/05/12 19:42, Emile van Sebille wrote: >>> from types import * >>> dir() ['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', '

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread ALAN GAULD
> > type(lambda : 0) >> > >> > is about as simple as you can do it with lambda... >> >> ...I think there should be a type.function avaliable in python, like str, >> int, etc. exists.  But there are many different function like objects just  as there are many different types of number.  Python does

[Tutor] PYLOTDB open source MySQL database management and analysis tool now available

2012-05-08 Thread Daniel Barnette
Many readers have asked whether there's Python GUI software for creating, managing, and analyzing MySQL databases. I have just released such software as completely open source. Source code is available on GitHub as follows: 1. Install Git on your machine from github.com 2. Initialize the target di

Re: [Tutor] Sorting a dictionary into a list cont'd

2012-05-08 Thread Prasad, Ramit
> Oh, and here's the error my program returns when it runs: > > Traceback (most recent call last): > File "/home/jacob/Dropbox/Shared_With_Chris_And_Logan/Jake's > Programs/Yet_To_Work_On/Synaptic/synaptic.py", line 57, in > neuron.smartest() > File "/home/jacob/Dropbox/Shared_With_Chris_

[Tutor] Sorting a dictionary into a list cont'd

2012-05-08 Thread Jacob Bender
Oh, and here's the error my program returns when it runs: Traceback (most recent call last): File "/home/jacob/Dropbox/Shared_With_Chris_And_Logan/Jake's Programs/Yet_To_Work_On/Synaptic/synaptic.py", line 57, in neuron.smartest() File "/home/jacob/Dropbox/Shared_With_Chris_And_Logan/Jake

[Tutor] Sorting the Parts of a Dictionary into a List

2012-05-08 Thread Jacob Bender
Dear Tutors, My original email was this: "Dear tutors, I'm trying to create a neural network program. Each neuron is in a dictionary and each of its connections and their strengths are in a nested dictionary. So {0:{1:4, 2:5}}, 1:{0:6}, 2:{1:2}} would mean that neuron 0 is connected to neuron 1

Re: [Tutor] List Indexing Issue

2012-05-08 Thread Joel Goldstick
On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis wrote: > Hello python community, > > I'm having a small issue with list indexing. I am extracting certain > information from a PDB (protein information) file and need certain fields of > the file to be copied into a list. The entries look like this:

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread xancorreu
Al 08/05/12 20:42, En/na Emile van Sebille ha escrit: On 5/8/2012 11:31 AM xancorreu said... isinstance(2, function) like I do isinstance(2, int) Do you understand my reasoning? Nope, but here ya go: Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11) [GCC 4.4.1] on linux2 Type "help"

[Tutor] List Indexing Issue

2012-05-08 Thread Spyros Charonis
Hello python community, I'm having a small issue with list indexing. I am extracting certain information from a PDB (protein information) file and need certain fields of the file to be copied into a list. The entries look like this: ATOM 1512 N VAL A 222 8.544 -7.133 25.697 1.00 48.

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread Walter Prins
On 8 May 2012 19:31, xancorreu wrote: > A much pain for me. I think there should be a type.function avaliable in > python, like str, int, etc. exists. I think as python is O-O language and > have (or at least the page says that) higher-order function, I should could > type: > Just define 'functi

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread Emile van Sebille
On 5/8/2012 11:31 AM xancorreu said... isinstance(2, function) like I do isinstance(2, int) Do you understand my reasoning? Nope, but here ya go: Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more informat

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread xancorreu
Al 08/05/12 19:36, En/na Alan Gauld ha escrit: On 08/05/12 11:23, xancorreu wrote: It works with c = Tag("twice", type(lambda x: x), lambda x: 2*x) but I want to specify the type of (lambda x: x) **manually** as I do with str in b Unfortunately we don't always get what we want. You have to

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread David Abbott
On Tue, May 8, 2012 at 1:41 PM, Alan Gauld wrote: > On 08/05/12 15:18, Rogelio wrote: >> >> While reading the subprocess documentation, I found a great example on >> how to call commands with a PIPE >> >> http://docs.python.org/library/subprocess.html >> >> ** >> output=`dm

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread Alan Gauld
On 08/05/12 15:18, Rogelio wrote: While reading the subprocess documentation, I found a great example on how to call commands with a PIPE http://docs.python.org/library/subprocess.html ** output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen([

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread Alan Gauld
On 08/05/12 11:23, xancorreu wrote: It works with c = Tag("twice", type(lambda x: x), lambda x: 2*x) but I want to specify the type of (lambda x: x) **manually** as I do with str in b Unfortunately we don't always get what we want. You have to use type for functions. You can use a very sim

Re: [Tutor] Displaying data in columns

2012-05-08 Thread Prasad, Ramit
> > I would like to display some of the items in the tuples in columnar > > format with each column lining up on the left side (below should be > > three neat columns with location, training type, number trained and > > date): > > You need to read up on string formatting. That allows you to specif

Re: [Tutor] IPcount = 0 when used with subprocess.call (use something to convert to integer?)

2012-05-08 Thread Prasad, Ramit
> def count_lines(filename): > with open(f, 'r') as in_stream: > return len(in_stream.readlines()) > > The count_lines function takes a filename and returns the number of > lines in that file. This way you avoid the problems with shell > metacharacters when using shell=True, mentioned

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread BRAGA, Bruno
No idea why you would want to do that (looks more complicated in python than in bash, right?)... but: f = open("log.txt", "w") f.write(output) f.close() -- *Braga, Bruno* www.brunobraga.net bruno.br...@gmail.com On Wed, May 9, 2012 at 12:18 AM, Rogelio wrote: > While reading the subprocess do

Re: [Tutor] Curious dictionary printing

2012-05-08 Thread Glen Zangirolami
Frankie, Dictionaries do not sort in python because it's much faster to leave it unordered and most of the time it isn't necessary. If you really need ordered dictionaries you can use http://pypi.python.org/pypi/ordereddict for Python <2.7. If you are using python 2.7+ then you can import it from

[Tutor] using subprocess to export files in bash

2012-05-08 Thread Rogelio
While reading the subprocess documentation, I found a great example on how to call commands with a PIPE http://docs.python.org/library/subprocess.html ** output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, std

Re: [Tutor] Curious dictionary printing

2012-05-08 Thread Dave Angel
On 05/08/2012 07:27 AM, Cranky Frankie wrote: > On Mon, May 7, 2012 at 10:31 PM, bob gailer wrote: > >> Asking why does it not do what I want is not IMHO the best way to win >> friends here. > Good morning to you to, Bob. > > I see now that dictionaries in Python act like relational databases in >

Re: [Tutor] Curious dictionary printing

2012-05-08 Thread Cranky Frankie
On Mon, May 7, 2012 at 10:31 PM, bob gailer wrote: > Asking why does it not do what I want is not IMHO the best way to win > friends here. Good morning to you to, Bob. I see now that dictionaries in Python act like relational databases in that there is no inherent ordering. At first, when I sim

Re: [Tutor] How can I have type "function" in my script?

2012-05-08 Thread xancorreu
Al 08/05/12 01:24, En/na Alan Gauld ha escrit: On 07/05/12 21:37, xancorreu wrote: This is the code: OK, But it's not clear from that why you want the type. You are not doing anything meaningful with the type. class Tag: def __init__(self, nom, tipus, valor): self.nom = nom self.tipus = ti

Re: [Tutor] Console Application - Key Events

2012-05-08 Thread Alan Gauld
On 08/05/12 02:44, BRAGA, Bruno wrote: I would like to know if there is any "easy" way to handle events (such as mouse movements, keyboard keys pressed, etc) in console based python applications? You need to be more specific about what you mean. Consoles don't have mice. Keyboard events are eas

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread शंतनू
On Tue, May 8, 2012 at 12:46 PM, शंतनू wrote: > Python generally comes with support for sqlite3. > > you can store your date in to sqlite db and then try running sql query > for finding of the details. data not date. > > select year, sum(MeanRain) where year='1972' group by year; > select month,

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread शंतनू
Python generally comes with support for sqlite3. you can store your date in to sqlite db and then try running sql query for finding of the details. select year, sum(MeanRain) where year='1972' group by year; select month, sum(MeanRain) where month='Jan' group by month; ** Not sure regarding the