Re: None shown in output

2012-06-21 Thread Xander Solis
Thanks for replying still! Appreciate the help. On Fri, Jun 22, 2012 at 12:25 PM, Benjamin Kaplan wrote: > damn > > On Thu, Jun 21, 2012 at 9:24 PM, Benjamin Kaplan > wrote: > > On Thu, Jun 21, 2012 at 8:42 PM, Xander Solis wrote: > >> Hello Python list, > >> > >> Noob here with a newbie questi

Re: None shown in output

2012-06-21 Thread Terry Reedy
On 6/21/2012 11:42 PM, Xander Solis wrote: Hello Python list, Noob here with a newbie question. I'm reading and working on the exercise of the book, Learn Python the Hard way 2.0. When I use this code, I get "None" on the output. My question is why does this happen? None is the default return

Re: None shown in output

2012-06-21 Thread Xander Solis
Thanks Andrew and Michael!. That did the trick. def get_numbers(first_num, second_num, operator): if operator == 'add': value = first_num + second_num elif operator == 'minus': value = first_num - second_num elif operator == 'divide': value = first_num / second

Re: None shown in output

2012-06-21 Thread Benjamin Kaplan
damn On Thu, Jun 21, 2012 at 9:24 PM, Benjamin Kaplan wrote: > On Thu, Jun 21, 2012 at 8:42 PM, Xander Solis wrote: >> Hello Python list, >> >> Noob here with a newbie question. I'm reading and working on the exercise of >> the book, Learn Python the Hard way 2.0. When I use this code, I get "No

Re: None shown in output

2012-06-21 Thread Dan Sommers
On Fri, 22 Jun 2012 11:42:28 +0800 Xander Solis wrote: > Noob here with a newbie question. I'm reading and working on the > exercise of the book, Learn Python the Hard way 2.0. When I use this > code, I get "None" on the output. My question is why does this happen? > > def get_numbers(first_num,

Re: None shown in output

2012-06-21 Thread Benjamin Kaplan
On Thu, Jun 21, 2012 at 8:42 PM, Xander Solis wrote: > Hello Python list, > > Noob here with a newbie question. I'm reading and working on the exercise of > the book, Learn Python the Hard way 2.0. When I use this code, I get "None" > on the output. My question is why does this happen? > > def get

Re: None shown in output

2012-06-21 Thread Andrew Berg
On 6/21/2012 10:42 PM, Xander Solis wrote: > Hello Python list, > > Noob here with a newbie question. I'm reading and working on the > exercise of the book, Learn Python the Hard way 2.0. When I use this > code, I get "None" on the output. My question is why does this happen? Your function prints

Re: None shown in output

2012-06-21 Thread Michael Hrivnak
The last three lines print the return value from the "get_numbers" function, which isn't returning anything. In python, the default return value is None, and that's why you're seeing it. Michael On Thu, Jun 21, 2012 at 11:42 PM, Xander Solis wrote: > Hello Python list, > > Noob here with a newb

None shown in output

2012-06-21 Thread Xander Solis
Hello Python list, Noob here with a newbie question. I'm reading and working on the exercise of the book, Learn Python the Hard way 2.0. When I use this code, I get "None" on the output. My question is why does this happen? def get_numbers(first_num, second_num, operator): if operator == 'ad

Re: bdist_wininst [was: Custom build of Python]

2012-06-21 Thread Mark Hammond
On 22/06/2012 3:10 AM, KACVINSKY Tom wrote: I found what I was looking for: python setup.py bdist_wininst bdist_wininst is for creating installers for Python packages which install into an existing Python directory structure. It isn't used to create a installer for Python itself (which

Re: inno setup 5.5

2012-06-21 Thread inq1ltd
On Friday, June 22, 2012 08:30:16 AM Chris Angelico wrote: > On Fri, Jun 22, 2012 at 1:34 AM, inq1ltd wrote: > > Can't find _thinter > > Is this supposed to be _tkinter? > > Try copying and pasting the entire error message, including traceback. > That often helps. At the moment, I can't know whe

Re: Help me with a bytes decoding problem in python 3

2012-06-21 Thread Chris Angelico
On Fri, Jun 22, 2012 at 8:30 AM, J wrote: > I'm wondering now... the way it works is that the program is run from > a user terminal/console.  however, on the other side (after the reboot > is done) it runs via an autostart script after the user is logged in, > and thus runs outside of the terminal

Re: Help me with a bytes decoding problem in python 3

2012-06-21 Thread J
On Thu, Jun 21, 2012 at 5:54 PM, Chris Angelico wrote: > On Fri, Jun 22, 2012 at 7:47 AM, J wrote: >> \xe2\x86\xb3 > > This is the UTF-8 encoded form of U+21B3, which is the DOWNWARDS ARROW > WITH TIP RIGHTWARDS character that you're showing. That's what the > "bytecode" you're seeing is. You may

Re: inno setup 5.5

2012-06-21 Thread Chris Angelico
On Fri, Jun 22, 2012 at 1:34 AM, inq1ltd wrote: > Can't find _thinter Is this supposed to be _tkinter? Try copying and pasting the entire error message, including traceback. That often helps. At the moment, I can't know whether the error is in your transcription of the message or if in a source

Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Gilles
On Thu, 21 Jun 2012 10:44:08 -0700, Paul Rubin wrote: >There are both kinds. The first kind is called a Virtual Private Server >(VPS). The second kind is called shared hosting. Thanks much for the infos. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me with a bytes decoding problem in python 3

2012-06-21 Thread Chris Angelico
On Fri, Jun 22, 2012 at 7:47 AM, J wrote: > \xe2\x86\xb3 This is the UTF-8 encoded form of U+21B3, which is the DOWNWARDS ARROW WITH TIP RIGHTWARDS character that you're showing. That's what the "bytecode" you're seeing is. You may be able to ask the underlying program to make its output in a cle

Help me with a bytes decoding problem in python 3

2012-06-21 Thread J
I have a bit of a problem I hope you could help me sort out with some code I'm porting from 2.x to 3. I have a program with a wrapper for Popen that is called to run certain linux shell commands and gather system info. Essentially the code looks something like this: process = subprocess.Popen(

[ANNOUNCE] greenlet 0.4.0

2012-06-21 Thread Ralf Schmitt
Hi, I have uploaded greenlet 0.4.0 to PyPI: http://pypi.python.org/pypi/greenlet What is it? --- The greenlet module provides coroutines for python. coroutines allow suspending and resuming execution at certain locations. concurrence[1], eventlet[2] and gevent[3] use the greenlet module

Re: how to compare below 2 json structure in python

2012-06-21 Thread MRAB
On 21/06/2012 19:16, hisan wrote: sample_json1={{ "globalControlId": 72, "value": 0, "controlId": 2 }, { "globalControlId": 77, "value": 3, "controlId": 7 } } sample_json2={ { "globalControlId": 77, "value": 3,

Re: how to compare below 2 json structure in python

2012-06-21 Thread John Gordon
In hisan writes: > sample_json1={{ >"globalControlId": 72, >"value": 0, >"controlId": 2 >}, >{ >"globalControlId": 77, >"value": 3, >"controlId": 7 >} > } > sample_json2={ >{ >"globalControlId": 77, >"value": 3, >

Re: Strange threading behaviour

2012-06-21 Thread Dave Angel
On 06/21/2012 02:03 PM, Rotwang wrote: > On 21/06/2012 18:07, Dave Angel wrote: >> On 06/21/2012 11:19 AM, Rotwang wrote: >>> Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written >>> is acting strangely. I can reproduce the behaviour in question with >>> the following: >>> >>> ---

Re: Strange threading behaviour

2012-06-21 Thread Rotwang
On 21/06/2012 18:37, Dennis Lee Bieber wrote: On Thu, 21 Jun 2012 16:19:41 +0100, Rotwang declaimed the following in gmane.comp.python.general: import threading, Tkinter, os, pickle class savethread(threading.Thread): def __init__(self, value): threading.Thread.__init__(self)

how to compare below 2 json structure in python

2012-06-21 Thread hisan
sample_json1={{ "globalControlId": 72, "value": 0, "controlId": 2 }, { "globalControlId": 77, "value": 3, "controlId": 7 } } sample_json2={ { "globalControlId": 77, "value": 3, "controlId": 7 }, { "globalContr

Re: Strange threading behaviour

2012-06-21 Thread Rotwang
On 21/06/2012 18:07, Dave Angel wrote: On 06/21/2012 11:19 AM, Rotwang wrote: Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is acting strangely. I can reproduce the behaviour in question with the following: --- begin bugtest.py --- import threading, Tkinter, os, pickle

bdist_wininst [was: Custom build of Python]

2012-06-21 Thread KACVINSKY Tom
I found what I was looking for: python setup.py bdist_wininst But... I follow all of the instructions for building Python on Windows and then follow the instructions for using bdist_wininst, and I get this: C:\Users\tky\Python\Python-2.6.8>PCbuild\amd64\python.exe setup.py bdist_wininst run

Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Paul Rubin
Gilles writes: > Do Python hosters provide a VM so that it's just like a remote Linux > server where I'm free to install whatever I want, or do they force > users to use specific versions of Python and specific frameworks eg. > Django? There are both kinds. The first kind is called a Virtual Pri

Re: Strange threading behaviour

2012-06-21 Thread inq1ltd
On Thursday, June 21, 2012 11:46:30 AM inq1ltd wrote: > On Thursday, June 21, 2012 04:19:41 PM Rotwang wrote: > > Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is > > acting strangely. I can reproduce the behaviour in question with the > > following: > > > > --- begin bugte

Re: Strange threading behaviour

2012-06-21 Thread Dieter Maurer
Rotwang writes: > Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written > is acting strangely. I can reproduce the behaviour in question with > the following: > > --- begin bugtest.py --- > > import threading, Tkinter, os, pickle > > class savethread(threading.Thread): > def _

Re: Strange threading behaviour

2012-06-21 Thread Temia Eszteri
On Thu, 21 Jun 2012 10:12:07 -0700, Temia Eszteri wrote: > >Try appending the dump command with f.flush() and os.fsync(). > >~Temia Actually, wait, no. The behavior you're describing is indicating that the thread in question isn't even getting a chance to execute at all. I'd recommend going with

Re: Strange threading behaviour

2012-06-21 Thread Temia Eszteri
On Thu, 21 Jun 2012 16:19:41 +0100, Rotwang wrote: >Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is >acting strangely. I can reproduce the behaviour in question with the >following: > >--- begin bugtest.py --- > >import threading, Tkinter, os, pickle > >class savethread

Re: Strange threading behaviour

2012-06-21 Thread Dave Angel
On 06/21/2012 11:19 AM, Rotwang wrote: > Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written > is acting strangely. I can reproduce the behaviour in question with > the following: > > --- begin bugtest.py --- > > import threading, Tkinter, os, pickle > > class savethread(threading

Re: Strange threading behaviour

2012-06-21 Thread inq1ltd
On Thursday, June 21, 2012 04:19:41 PM Rotwang wrote: > Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is > acting strangely. I can reproduce the behaviour in question with the > following: > > --- begin bugtest.py --- > > import threading, Tkinter, os, pickle try this; f

Re: Generator vs functools.partial?

2012-06-21 Thread J. Cliff Dyer
On Thu, 2012-06-21 at 21:25 +1000, John O'Hagan wrote: > Sometimes a function gets called repeatedly with the same expensive argument: > > def some_func(arg, i): > (do_something with arg and i) > > same_old_arg = big_calculation() > for i in lots_of_items: > some_func(same_old_arg, i) >

inno setup 5.5

2012-06-21 Thread inq1ltd
py help, Can someone let me know where to get help with inno setup. I get an error; Can't find _thinter Sounds like a path problem. Everything works until it is packaged with inno v5.5. jd -- http://mail.python.org/mailman/listinfo/python-list

Parse command line output using textfsm

2012-06-21 Thread Ferdinand Sousa
Hi List, I am using python to run command line utilities on Linux machine. I came across textfsm and feel that it fits my requirements. Here is the structure of the output from the 2 utilities Command 1: Id AddressPort Location State Tenant count Max tenants Description -- --

Strange threading behaviour

2012-06-21 Thread Rotwang
Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is acting strangely. I can reproduce the behaviour in question with the following: --- begin bugtest.py --- import threading, Tkinter, os, pickle class savethread(threading.Thread): def __init__(self, value): th

Re: Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
On Thu, 21 Jun 2012 14:20:23 +0200 Thomas Rachel wrote: > Am 21.06.2012 13:25 schrieb John O'Hagan: > > > But what about a generator? > > Yes, but... > > > def some_func(): > > arg = big_calculation() > > while 1: > > i = yield > > (do_something with arg and i) > >

Re: Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
On 21 Jun 2012 12:19:20 GMT Steven D'Aprano wrote: > On Thu, 21 Jun 2012 21:25:04 +1000, John O'Hagan wrote: > > > Sometimes a function gets called repeatedly with the same expensive > > argument: > > > > def some_func(arg, i): > > (do_something with arg and i) > > > > same_old_arg = big_c

Re: Introspect imports from module

2012-06-21 Thread Bastian Ballmann
Hi, that's really great stuff! I love it! Thx :) Am Thu, 21 Jun 2012 13:00:36 +0200 schrieb Christian Heimes : > Am 21.06.2012 10:03, schrieb Bastian Ballmann: > > Any suggestions how I could just get the import of > > module.to.inspect? Thanks && have a nice day! > > You could try a completel

Re: fastest method

2012-06-21 Thread Jean-Michel Pichavant
david.gar...@gmail.com wrote: I am looking for the fastest way to parse a log file. currently I have this... Can I speed this up any? The script is written to be a generic log file parser so I can't rely on some predictable pattern. def check_data(data,keywords): #get rid of duplicates

Re: Generator vs functools.partial?

2012-06-21 Thread Thomas Rachel
Am 21.06.2012 13:25 schrieb John O'Hagan: But what about a generator? Yes, but... def some_func(): arg = big_calculation() while 1: i = yield (do_something with arg and i) some_gen = some_func() some_gen.send(None) for i in lots_of_items: some_gen.send(i)

Re: [newbie] Equivalent to PHP?

2012-06-21 Thread Gilles
On Tue, 12 Jun 2012 11:39:50 +0200, Gilles wrote: >I'm an amateur programmer, and would like to know what the main >options are to build web applications in Python instead of PHP. When I need to host my Python application (preferably in Europe since my users will be located there), what are the o

Re: Generator vs functools.partial?

2012-06-21 Thread Steven D'Aprano
On Thu, 21 Jun 2012 21:25:04 +1000, John O'Hagan wrote: > Sometimes a function gets called repeatedly with the same expensive > argument: > > def some_func(arg, i): > (do_something with arg and i) > > same_old_arg = big_calculation() Since big_calculation() is only called once, the cost of

Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
Sometimes a function gets called repeatedly with the same expensive argument: def some_func(arg, i): (do_something with arg and i) same_old_arg = big_calculation() for i in lots_of_items: some_func(same_old_arg, i) A simple case like that looks OK, but it can get messy when groups of arg

Re: Introspect imports from module

2012-06-21 Thread Christian Heimes
Am 21.06.2012 10:03, schrieb Bastian Ballmann: > Any suggestions how I could just get the import of module.to.inspect? > Thanks && have a nice day! You could try a completely different approach and use the compiler package to inspect the abstract syntrax tree of a compiled module. The approach has

using SQLalchemy

2012-06-21 Thread andrea crotti
We have a very chaotic database (on MySql) at the moment, with for example table names used as keys to query other tables (but that's just an example). We are going to redesign it but first I still have to replace the perl+vbscript system with only one Python program, so I still have to deal with

Introspect imports from module

2012-06-21 Thread Bastian Ballmann
Hi all, I am trying to write a function that returns a list of imports a given module is doing. The "problem" is I dont want to get the imports of the imports, but that's the case with my current solution. import __builtin__ old_import = __builtin__.__import__ def import_hook(name, globals=None,