Re: learning python. learning defining functions . need help

2016-07-22 Thread Steven D'Aprano
On Sat, 23 Jul 2016 01:21 am, justin walters wrote: > That should illustrate why. This is because simply typing '{}' could be > interpreted as > either a dict or a set. No. {} is always an empty dict. That is a language guarantee. Any programming language where {} is not an empty disk is not val

Re: learning python. learning defining functions . need help

2016-07-22 Thread MRAB
On 2016-07-22 16:41, D'Arcy J.M. Cain wrote: On Fri, 22 Jul 2016 08:21:17 -0700 justin walters wrote: You could also replace that line with: if stock is None or type(stock) != dict: Use isinstance(). That handles classes that subclass dict as well. If you're checking that it's a dict,

Re: learning python. learning defining functions . need help

2016-07-22 Thread D'Arcy J.M. Cain
On Fri, 22 Jul 2016 08:21:17 -0700 justin walters wrote: > You could also replace that line with: > > if stock is None or type(stock) != dict: Use isinstance(). That handles classes that subclass dict as well. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@

Re: learning python. learning defining functions . need help

2016-07-22 Thread Random832
On Fri, Jul 22, 2016, at 11:21, justin walters wrote: > Try opening the interactive terminal on your command line and type the > following: > > type({}) == dict() > > That should illustrate why. That doesn't illustrate anything relevant at all. The reason this is false is because dict() is

Re: learning python. learning defining functions . need help

2016-07-22 Thread Chris Angelico
On Sat, Jul 23, 2016 at 1:21 AM, justin walters wrote: > Hi Chris, > > Try opening the interactive terminal on your command line and type the > following: > > type({}) == dict() > > That should illustrate why. This is because simply typing '{}' could be > interpreted as > either a dict or a se

Re: learning python. learning defining functions . need help

2016-07-22 Thread justin walters
On Fri, Jul 22, 2016 at 6:24 AM, Chris Angelico wrote: > On Fri, Jul 22, 2016 at 11:13 PM, Dennis Lee Bieber > wrote: > > Now... Going much beyond the assignment (if you were having > trouble > > with the assignment, this will seem like magic) [Python 2.7]: > > I'm not sure, but I think

Re: learning python. learning defining functions . need help

2016-07-22 Thread Chris Angelico
On Fri, Jul 22, 2016 at 11:13 PM, Dennis Lee Bieber wrote: > Now... Going much beyond the assignment (if you were having trouble > with the assignment, this will seem like magic) [Python 2.7]: I'm not sure, but I think your code would become Py3 compatible if you just change your prints.

learning python. learning defining functions . need help

2016-07-21 Thread sigmaphine1914
having a little trouble with defining functions. i have a doc called ch5.py and when i was trying the following i had issues " Try It Out: Defining a Function Try saving the following in your file for Chapter 5, ch5.py.def in_fridge(): try: count = fridge[wanted

Re: defining functions

2007-04-08 Thread rweth
Andre P.S Duarte wrote: > How do I define a function, then import it, without having to save it > in lib; like "C:\python25\lib". ? > The best way I have found (in windows ) for permanently extending your search path for modules is to create the file: package.pth and put your path/s in a line

Re: defining functions

2007-04-05 Thread 7stud
On Apr 5, 12:38 pm, "Andre P.S Duarte" <[EMAIL PROTECTED]> wrote: > How do I define a function, then import it, without having to save it > in lib; like "C:\python25\lib". ? ...or permanently set your PYTHONPATH environment variable to the folders you want python to look in for the modules you imp

Re: defining functions

2007-04-05 Thread kyosohma
On Apr 5, 1:38 pm, "Andre P.S Duarte" <[EMAIL PROTECTED]> wrote: > How do I define a function, then import it, without having to save it > in lib; like "C:\python25\lib". ? Defining a function: def someFunc(): # do something here Save the file some place. Import the sys module BEFORE you imp

defining functions

2007-04-05 Thread Andre P.S Duarte
How do I define a function, then import it, without having to save it in lib; like "C:\python25\lib". ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Defining functions in an implementation file

2006-07-18 Thread Yu-Xi Lim
westymatt wrote: > I am fairly new to python and I want to put alot of my functions in > another python file and import or from it into my script so I can call > the functions. How is this done? > What you are describing are modules. The Python Tutorial has some information on this http://docs.

Re: Defining functions in an implementation file

2006-07-18 Thread Diez B. Roggisch
westymatt schrieb: > I am fairly new to python and I want to put alot of my functions in > another python file and import or from it into my script so I can call > the functions. How is this done? import myfilefullofusefulfunctionsandclasses Works if you have the file myfilefullofusefulfuncti

Defining functions in an implementation file

2006-07-18 Thread westymatt
I am fairly new to python and I want to put alot of my functions in another python file and import or from it into my script so I can call the functions. How is this done? -- http://mail.python.org/mailman/listinfo/python-list