Re: [Python-ideas] Allow filter(items)

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 9:23 AM, Serhiy Storchaka wrote: > 06.08.13 10:34, Chris Angelico написав(ла): > >> Okay. Sounds like there's already an answer to those who want more >> readability: Just use filter(bool,...). Maybe I'm just not seeing the >> obvious problem with this version? > > > Are `if

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Ben Finney wrote: > Rui Maciel writes: > >> Is there any pythonic way to perform static typing? > > I think no; static typing is inherently un-Pythonic. > > Python provides strong, dynamic typing. Enjoy it! Bummer. >> Does anyone care to enlighten a newbie? > > Is there some specific prob

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Steven D'Aprano wrote: > On Mon, 05 Aug 2013 21:46:57 +0100, Rui Maciel wrote: > >> Is there any pythonic way to perform static typing? After searching the >> web I've stumbled on a significant number of comments that appear to >> cover static typing as a proof of concept , but in the process I'

Reg secure python environment with web terminal emulator

2013-08-06 Thread Lakshmipathi.G
Hi - We have a server running a web-based terminal emulator (based on shellinabox for screen-casting check www.webminal.org) that allows users to learn simple bash commands. This Linux environment secured by things like quota, selinux,ulimit etc Now some users are requesting python access. How

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Gary Herron wrote: > The Pythonic way is to *enjoy* the freedom and flexibility and power of > dynamic typing. If you are stepping out of a static typing language > into Python, don't step just half way. Embrace dynamic typing. (Like > any freedom, it can bite you at times, but that's no reason

Class hierarchy problem

2013-08-06 Thread BrJohan
I'm in need of help to solve this Python (ver. 3.3) problem: I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, SubC,...), each of which is inheriting from a chain of superclasses with a common baseclass(Sup) on top. (So far, no problem) Now, I want to create instances of the corr

Re: Module for dialoging with intercative programs, sockets, files, etc.

2013-08-06 Thread Ulrich Eckhardt
Am 05.08.2013 21:38, schrieb Olive: I have found telnetlib which make very easy to interact with a telnet server, especially the read_until command. I wonder if something similar exits for other things that a telnet server. It's not Python and I haven't played with it extensively, but there is

Re: Newbie: static typing?

2013-08-06 Thread Joshua Landau
On 6 August 2013 10:01, Rui Maciel wrote: > Ben Finney wrote: > >> Rui Maciel writes: >> >>> Is there any pythonic way to perform static typing? >> >> I think no; static typing is inherently un-Pythonic. >> >> Python provides strong, dynamic typing. Enjoy it! > > Bummer. It's really not. >>> D

Re: Newbie: static typing?

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 10:01 AM, Rui Maciel wrote: > It would be nice if some functions threw an error if they were passed a type > they don't support or weren't designed to handle. That would avoid having > to deal with some bugs which otherwise would never happen. > > To avoid this sort of erro

Re: Newbie: static typing?

2013-08-06 Thread Steven D'Aprano
On Tue, 06 Aug 2013 10:05:57 +0100, Rui Maciel wrote: > What's the Python way of dealing with objects being passed to a function > that aren't of a certain type, have specific attributes of a specific > type, nor support a specific interface? Raise TypeError, or just let the failure occurs howeve

Re: Newbie: static typing?

2013-08-06 Thread Joshua Landau
On 6 August 2013 10:05, Rui Maciel wrote: > Gary Herron wrote: > >> The Pythonic way is to *enjoy* the freedom and flexibility and power of >> dynamic typing. If you are stepping out of a static typing language >> into Python, don't step just half way. Embrace dynamic typing. (Like >> any freed

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 10:10 AM, BrJohan wrote: > Now, I want to create instances of the correct subclasstype as decided by > the common baseclass, like this: > > i = Sup(args_allowing_the_baseclass_to_deduce_correct_subclass) > > where i can be of any class except Sup itself (as decided by Sup)

Re: Class hierarchy problem

2013-08-06 Thread Peter Otten
BrJohan wrote: > I'm in need of help to solve this Python (ver. 3.3) problem: > > I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, > SubC,...), each of which is inheriting from a chain of superclasses with > a common baseclass(Sup) on top. (So far, no problem) > > Now, I want to cr

Re: Class hierarchy problem

2013-08-06 Thread Steven D'Aprano
On Tue, 06 Aug 2013 11:10:17 +0200, BrJohan wrote: > I'm in need of help to solve this Python (ver. 3.3) problem: > > I have a hierarchy of classes (SubA, SubAB, SubB, ..., SubBCA, > SubC,...), each of which is inheriting from a chain of superclasses with > a common baseclass(Sup) on top. (So far

Re: Source code to identify user through browser?

2013-08-06 Thread Gilles
On Wed, 05 Jun 2013 15:08:54 +0200, Gilles wrote: >I was wondering if some Python module were available to identify a >user through their browser, like it's done on the Panopticlick site: > >http://panopticlick.eff.org/ It appears that flash cookies is a better solution to keep most trolls away f

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Joshua Landau wrote: > Unless you have a very good reason, don't do this. It's a damn pain > when functions won't accept my custom types with equivalent > functionality -- Python's a duck-typed language and it should behave > like one. In that case what's the pythonic way to deal with standard ca

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Joshua Landau wrote: > What's the actual problem you're facing? Where do you feel that you > need to verify types? A standard case would be when there's a function which is designed expecting that all operands support a specific interface or contain specific attributes. In other words, when pa

Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Chris Angelico wrote: > On Tue, Aug 6, 2013 at 10:01 AM, Rui Maciel wrote: >> It would be nice if some functions threw an error if they were passed a >> type >> they don't support or weren't designed to handle. That would avoid >> having to deal with some bugs which otherwise would never happen.

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 10:19 PM, MRAB wrote: On 06/08/2013 03:00, Devyn Collier Johnson wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('/home/collier/py

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 10:19 PM, MRAB wrote: On 06/08/2013 03:00, Devyn Collier Johnson wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept newline characters. >>> file = open('/home/collier/py

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 11:49 PM, alex23 wrote: On 6/08/2013 1:12 PM, Joshua Landau wrote: Because it's bad to open files without a with unless you know what you're doing, use a with: with open('/home/collier/pytest/__sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Shoul

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/05/2013 11:12 PM, Joshua Landau wrote: On 6 August 2013 03:00, Devyn Collier Johnson > wrote: I am wanting to sort a plain text file alphanumerically by the lines. I have tried this code, but I get an error. I assume this command does not accept

[GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Gilles
Hello I need to write a small GUI application that should run on Windows and Mac. What open-source framework would you recommend? I just need basic widgets (button, listbox, etc.) and would rather a solution that can get me up and running fast. I know about wxWidgets and Qt: Are there other good

Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-06 Thread Gilles
On Sat, 3 Aug 2013 06:47:07 -0500 (CDT), Wayne Werner wrote: >Have you checked Kenneth Rietz's inbox.py[1]? It's fairly simple to >use/extend and might fit your modest needs. > > >-W > >[1]:https://crate.io/packages/inbox/ Thanks. I'll check it out. -- http://mail.python.org/mailman/listinfo/py

Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-06 Thread Gilles
On Sat, 03 Aug 2013 21:41:16 -0400, Kevin Walzer wrote: >For what it's worth, that hasn't been my experience. Thanks for the feedback. I'll experiment and see how it goes. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: static typing?

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 11:28 AM, Rui Maciel wrote: > Chris Angelico wrote: >> def add_three_values(x,y,z): >> return x+y+z >> >> Do you want to test these values for compatibility? Remember, you >> could take a mixture of types, as most of the numeric types can safely >> be added. You can also

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson wrote: > with open('/home/collier/pytest/sort.TXT') as file: > sorted(file, key=str.casefold, reverse=True) > > > Thanks for the advice Joshua. I find these tips very useful. However, how > would I close the files, or would they cl

Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-06 Thread Gilles
On Sat, 3 Aug 2013 10:57:32 -0700 (PDT), Aseem Bansal wrote: >I found Python3's sqlite3 library. I found that I needed sql commands for >using it. > >I have tried sql.learncodethehardway but it isn't complete yet. I tired >looking on stackoverflow's sql tag also but nothing much there. It'll b

Re: Creating a running tally/ definitely new to this

2013-08-06 Thread gratedmedia
Yes I want to store an amount of money which will change from many places within the code. Absolutely correct. I am very "green" to this, if you're familiar, with "dopewars" the concept is very similar. for my practice trials I used.. selection_b = input() and manually input an amount of mon

Re: [GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Vlastimil Brom
2013/8/6 Gilles : > Hello > > I need to write a small GUI application that should run on Windows and > Mac. > > What open-source framework would you recommend? I just need basic > widgets (button, listbox, etc.) and would rather a solution that can > get me up and running fast. > > I know about wxW

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Joshua Landau
On 6 August 2013 11:52, Chris Angelico wrote: > On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson > wrote: >> with open('/home/collier/pytest/sort.TXT') as file: >> sorted(file, key=str.casefold, reverse=True) >> >> >> Thanks for the advice Joshua. I find these tips very useful.

Re: Working with XML/XSD

2013-08-06 Thread Verde Denim
On 08/05/2013 06:56 PM, David Barroso wrote: > Hello, > I was wondering if someone could point me in the right direction. I > would like to develop some scripts to manage Cisco routers and > switches using XML. However, I am not sure where to start. Does > someone have some experience working with

Re: [GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Jordi Riera
Hey you can build GUIs with tkinter . Easy but not as powerful than PyQt can be. I think it is os agnostic. Regards, Jordi On Tue, Aug 6, 2013 at 12:35 PM, Gilles wrote: > Hello > > I need to write a small GUI application that should run on Windows and > M

Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-06 Thread Jordi Riera
Hey, can't you use django to deal with your sqlite? If so, django modelsare a smart way to do. Regards, Jordi On Tue, Aug 6, 2013 at 12:51 PM, Gilles wrote: > On Sat, 3 Aug 2013 10:57:32 -0700 (PDT), Aseem Bansal > wrote: > >I found Py

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Devyn Collier Johnson
On 08/06/2013 06:52 AM, Chris Angelico wrote: On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson wrote: with open('/home/collier/pytest/sort.TXT') as file: sorted(file, key=str.casefold, reverse=True) Thanks for the advice Joshua. I find these tips very useful. However, how

Re: Sort lines in a plain text file alphanumerically

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 12:44 PM, Joshua Landau wrote: > On 6 August 2013 11:52, Chris Angelico wrote: >> On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson >> wrote: >>> with open('/home/collier/pytest/sort.TXT') as file: >>> sorted(file, key=str.casefold, reverse=True) >>> >>> >

Re: Newbie: static typing?

2013-08-06 Thread Burak Arslan
On 08/06/13 13:12, Rui Maciel wrote: > Joshua Landau wrote: > >> What's the actual problem you're facing? Where do you feel that you >> need to verify types? > A standard case would be when there's a function which is designed expecting > that all operands support a specific interface or contain s

Re: Working with XML/XSD

2013-08-06 Thread Burak Arslan
On 08/06/13 01:56, David Barroso wrote: > Hello, > I was wondering if someone could point me in the right direction. I > would like to develop some scripts to manage Cisco routers and > switches using XML. However, I am not sure where to start. Does > someone have some experience working with XML,

Re: Newbie: static typing?

2013-08-06 Thread Antoon Pardon
Op 06-08-13 15:27, Burak Arslan schreef: > On 08/06/13 13:12, Rui Maciel wrote: >> Joshua Landau wrote: >> >>> What's the actual problem you're facing? Where do you feel that you >>> need to verify types? >> A standard case would be when there's a function which is designed expecting >> that all o

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 2:58 PM, BrJohan wrote: > On 06/08/2013 11:30, Chris Angelico wrote: >> >> On Tue, Aug 6, 2013 at 10:10 AM, BrJohan wrote: >>> >>> Now, I want to create instances of the correct subclasstype as decided by >>> the common baseclass, like this: >>> >>> i = Sup(args_allowing_th

Re: Newbie: static typing?

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 2:57 PM, Antoon Pardon wrote: > Op 06-08-13 15:27, Burak Arslan schreef: >> On 08/06/13 13:12, Rui Maciel wrote: >>> Joshua Landau wrote: >>> What's the actual problem you're facing? Where do you feel that you need to verify types? >>> A standard case would be when

Re: Newbie: static typing?

2013-08-06 Thread Eric S. Johansson
On Tue, 06 Aug 2013 09:27:10 -0400, Burak Arslan wrote: First, let's get over the fact that, with dynamic typing, code fails at runtime. Irrespective of language, you just shouldn't ship untested code, so I say that's not an argument against dynamic typing. It's not so much shipping unteste

Pylint 1.0 released

2013-08-06 Thread Sylvain Thénault
Hi there, at last, Pylint 1.0 is out! See http://www.logilab.org/blogentry/163292 for (much) more info and enjoy! And many thanks to every one who contributed to this release... -- Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42) Formations Python, Debian, Méth. Agil

Re: Module for dialoging with intercative programs, sockets, files, etc.

2013-08-06 Thread William Ray Wing
On Aug 6, 2013, at 4:44 AM, Ulrich Eckhardt wrote: > Am 05.08.2013 21:38, schrieb Olive: >> I have found telnetlib which make very easy to interact with a telnet >> server, especially the read_until command. I wonder if something >> similar exits for other things that a telnet server. > > It's

Re: Newbie: static typing?

2013-08-06 Thread Rotwang
On 06/08/2013 11:07, Rui Maciel wrote: Joshua Landau wrote: Unless you have a very good reason, don't do this [i.e. checking arguments for type at runtime and raising TypeError]. It's a damn pain when functions won't accept my custom types with equivalent functionality -- Python's a duck-typed

Re: Newbie: static typing?

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 2:58 PM, Eric S. Johansson wrote: > I guess this is a long way of saying instrument your software so that it can > be tested and or give you enough information about the internal state. This > is sort of like building a specialized integrated circuit. You need to > design it

Re: Newbie: static typing?

2013-08-06 Thread Grant Edwards
On 2013-08-05, Rui Maciel wrote: > Is there any pythonic way to perform static typing? No. One of the fundamental characteristics of Python is dynamic typing. Without dynamic typing, it wouldn't _be_ Python. -- Grant Edwards grant.b.edwardsYow! I wonder if I ought

Re: Creating a running tally/ definitely new to this

2013-08-06 Thread gratedmedia
On Monday, August 5, 2013 10:15:30 PM UTC-4, Dave Angel wrote: > gratedme...@gmail.com wrote: > > > > > > > > I currently working on a game, where I need to maintain a running tally of > > money, as the player makes purchases as they navigate thru game. I not > > exactly sure how to do this

Re: Class hierarchy problem

2013-08-06 Thread BrJohan
On 06/08/2013 16:02, Chris Angelico wrote: My classhierarchy is like a multilevel tree where each non-leaf node (class) is given knowledge about its nearest subclasses and their 'capacities'. So, my idea is to let the 'upper' class recursively choose which of its nearest subclasses is the 'corr

pexpect, loading an entry field

2013-08-06 Thread inq1ltd
python help; I am using pexpect to open my program. Can someone tell me how to get data to appear in an entry field. After pexpect opens the my program I have tried to use send, sendline, and write functions to try to put data into the program's entry field. However, the data is going to the

Re: Simulate `bash` behaviour using Python and named pipes.

2013-08-06 Thread Luca Cerone
> my_thread.join() Thanks! I managed to make it work using the threading library :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Pylint 1.0 released

2013-08-06 Thread Jordi Riera
Great tool Thanks! On Tue, Aug 6, 2013 at 4:12 PM, Sylvain Thénault < sylvain.thena...@logilab.fr> wrote: > Hi there, > > at last, Pylint 1.0 is out! See http://www.logilab.org/blogentry/163292 > for (much) more info and enjoy! > > And many thanks to every one who contributed to this release...

Re: Class hierarchy problem

2013-08-06 Thread Joe Junior
On Tue, Aug 6, 2013 at 12:36 PM, BrJohan wrote: > On 06/08/2013 16:02, Chris Angelico wrote: > >>> My classhierarchy is like a multilevel tree where each non-leaf node >>> (class) >>> is given knowledge about its nearest subclasses and their 'capacities'. >>> >>> So, my idea is to let the 'upper'

Re: Class hierarchy problem

2013-08-06 Thread Jordi Riera
Are you using a db for that? Django models would handle that pretty easily: class Species(models.Model): name = models.CharField() class Genus(models.Model): name = models.CharField() species = models.ManyToManyField( Species, related_name = 'genus_species' ) then you

Re: pexpect, loading an entry field

2013-08-06 Thread Lakshmipathi.G
pexpect looks simple to use. Please check this example http://www.pythonforbeginners.com/systems-programming/how-to-use-the-pexpect-module-in-python/ -- Cheers, Lakshmipathi.G FOSS Programmer. www.giis.co.in On Tue, Aug 6, 2013 at 8:35 PM, inq1ltd wrote: > python help; > > > > I am using p

Re: Python-list Digest, Vol 119, Issue 37

2013-08-06 Thread Yimr Wong
>I found Python3's sqlite3 library. I found that I needed sql commands for using it. > >I have tried sql.learncodethehardway but it isn't complete yet. I tired looking on stackoverflow's sql tag also but nothing much there. There is some useful references in the Python's documents. If you want to

Re: Class hierarchy problem

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 4:36 PM, BrJohan wrote: > Consider a botanical classification system (somewhat analogous to my > 'problem' as it effectively is related to classification of entities): > > A Domain should know about its Kingdoms, > a Kingdom should know about its Phylums, > ... > a Genus sho

Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
Hi guys, I would like to apply the Pool.map method to a member of a class. Here is a small example that shows what I would like to do: from multiprocessing import Pool class A(object): def __init__(self,x): self.value = x def fun(self,x): return self.value**x l = range(10)

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 6:12 PM, Luca Cerone wrote: > from multiprocessing import Pool > > class A(object): >def __init__(self,x): >self.value = x >def fun(self,x): >return self.value**x > > > l = range(10) > > p = Pool(4) > > op = p.map(A.fun,l) Do you ever instantiate any

Re: pexpect, loading an entry field

2013-08-06 Thread inq1ltd
> pexpect looks simple to use. Please check this example > http://www.pythonforbeginners.com/systems-programming/how-to-use-the- pexpect > -module-in-python/ > > python help; > > > > I am using pexpect to open my program. > > Can someone tell me how to get data to appear in > > an entry field. >

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
On Tuesday, 6 August 2013 18:12:26 UTC+1, Luca Cerone wrote: > Hi guys, > > I would like to apply the Pool.map method to a member of a class. > > > > Here is a small example that shows what I would like to do: > > > > from multiprocessing import Pool > > > > class A(object): > >def

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
Hi Chris, thanks > Do you ever instantiate any A() objects? You're attempting to call an > > unbound method without passing it a 'self'. I have tried a lot of variations, instantiating the object, creating lambda functions that use the unbound version of fun (A.fun.__func__) etc etc.. I have pl

lxml tostring quoting too much

2013-08-06 Thread andrea crotti
I would really like to do the following: from lxml import etree as ET from lxml.builder import E url = "http://something?x=10&y=20"; l = E.link(url) ET.tostring(l) -> "http://something?x=10&y=20" However the lxml tostring always quotes the &, I can't find a way to tell it to avoid quoting it. Is

Re: lxml tostring quoting too much

2013-08-06 Thread Chris Down
On 2013-08-06 18:38, andrea crotti wrote: > I would really like to do the following: > > from lxml import etree as ET > from lxml.builder import E > > url = "http://something?x=10&y=20"; > l = E.link(url) > ET.tostring(l) -> "http://something?x=10&y=20" > > However the lxml tostring always quotes t

Beginner question

2013-08-06 Thread eschneider92
Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter what is typed. Much thanks. def thing(): print('go again?') goagain=input() if goagain=='y' or 'yes': print('ok') elif goagain!='y' or 'yes': print('goodbye') sys.exit() thing()

Re: Beginner question

2013-08-06 Thread Dave Angel
eschneide...@comcast.net wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. > > def thing(): > print('go again?') > goagain=input() > if goagain=='y' or 'yes': This expression doesn't do what you think. The compariso

Re: Beginner question

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 10:35 PM, wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. > > def thing(): > print('go again?') > goagain=input() > if goagain=='y' or 'yes': > print('ok') > elif goagain!='y' or

Re: [GUI] Good frameworks for Windows/Mac?

2013-08-06 Thread Gilles
On Tue, 6 Aug 2013 13:22:01 +0200, Vlastimil Brom wrote: >I mostly use wxPython myself, but if you just need some basic widgets >and not some very complex or non-standard layouts, the tkinter - >available in the standard library - might be perfectly viable. >http://docs.python.org/3.3/library/tk.h

[ActivePython] Upgrading fails

2013-08-06 Thread Gilles
Hello, I already posted in their forum, but got no reply and figured some people here might have experienced this too. I'm currently running ActivePython 2.5.1.1 on my XP Pro host. After downloading and running the installer to 2.7.2.5, I get the following error message: "Windows Installer: The

Re: Beginner question

2013-08-06 Thread Rhodri James
On Tue, 06 Aug 2013 22:35:44 +0100, wrote: Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter what is typed. Much thanks. def thing(): print('go again?') goagain=input() if goagain=='y' or 'yes': This line doesn't do what you think it does :-) Typin

Easier to Ask Forgiveness than Permission (was: Newbie: static typing?)

2013-08-06 Thread Ben Finney
Rui Maciel writes: > Gary Herron wrote: > > > The Pythonic way is to *enjoy* the freedom and flexibility and power > > of dynamic typing. If you are stepping out of a static typing > > language into Python, don't step just half way. Embrace dynamic > > typing. (Like any freedom, it can bite you a

[tkinter] trouble running imported modules in main program

2013-08-06 Thread snakeinmyboot
Hello, I am currently just starting to learn the basics of the tkinter module and ive run into a problem. To teach myself I am messing around by creating separate modules containing basic GUI apps like a tip calculator and kilometer converter, then creating a main program that displays buttons

Re: Newbie: static typing?

2013-08-06 Thread Ben Finney
Rui Maciel writes: > class AbstractVisitor(object): > def visit(self, element): > pass A small improvement to your code: If you want an abstract method – that is, a method which should not be called directly but which sub-classes should over-ride – then your abstract met

HTTP post with urllib2

2013-08-06 Thread cerr
Hi, Why does this code: #!/usr/bin/python import urllib2 from binascii import hexlify, unhexlify host = "localhost" uri="/test.php" data ="\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64" #Hello World url="http://{0}{1}?f=test".format(host, uri) req = urllib2.Request(url, data,{'Content-Type': 'appli

Enum vs OrderedEnum

2013-08-06 Thread Ian Kelly
Using the OrderedEnum recipe from the Python 3.4 docs, I have the following code: class Environment(OrderedEnum): gaia = 1 fertile = 2 terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10) barren, tundra, dead, inferno, toxic, radiated = range(10, 16) def is_st

Re: Newbie: static typing?

2013-08-06 Thread Terry Reedy
On 8/6/2013 6:50 AM, Chris Angelico wrote: On Tue, Aug 6, 2013 at 11:28 AM, Rui Maciel wrote: Chris Angelico wrote: def add_three_values(x,y,z): return x+y+z Do you want to test these values for compatibility? Remember, you could take a mixture of types, as most of the numeric types can

Re: HTTP post with urllib2

2013-08-06 Thread Joel Goldstick
On Tue, Aug 6, 2013 at 6:52 PM, cerr wrote: > Hi, > > Why does this code: > > #!/usr/bin/python > > > import urllib2 > from binascii import hexlify, unhexlify > > host = "localhost" > uri="/test.php" > data ="\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64" #Hello World > url="http://{0}{1}?f=test".forma

Re: Enum vs OrderedEnum

2013-08-06 Thread Ethan Furman
On 08/06/2013 04:00 PM, Ian Kelly wrote: Use the .value attribute instead. You could also substitute self for Environment. class Environment(Enum): gaia = 1 fertile = 2 terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10) barren, tundra, dead, inferno, tox

Re: Class hierarchy problem

2013-08-06 Thread Terry Reedy
On 8/6/2013 11:36 AM, BrJohan wrote: Consider a botanical classification system (somewhat analogous to my 'problem' as it effectively is related to classification of entities): A Domain should know about its Kingdoms, a Kingdom should know about its Phylums, ... a Genus should know about its Sp

Re: [argparse] mutually exclusive group with 2 sets of options

2013-08-06 Thread Francois Lafont
Hi, On relfection, it's clear that: 1. the "(-a -b VALUE-B | -c -d VALUE-D)" syntax is not implemented by the argparse module; 2. and get this syntax with "argparse + hacking" is not very clean. So, finally I'll use the docopt module version 0.6.1. For the inheritance of common options, I'll us

Re: [tkinter] trouble running imported modules in main program

2013-08-06 Thread Terry Reedy
On 8/6/2013 6:28 PM, snakeinmyboot wrote: Hello, I am currently just starting to learn the basics of the tkinter module and ive run into a problem. To teach myself I am messing around by creating separate modules containing basic GUI apps like a tip calculator and kilometer converter, then cr

Re: HTTP post with urllib2

2013-08-06 Thread cerr
On Tuesday, August 6, 2013 4:08:34 PM UTC-7, Joel Goldstick wrote: > On Tue, Aug 6, 2013 at 6:52 PM, cerr wrote: > > > Hi, > > > > > > Why does this code: > > > > > > #!/usr/bin/python > > > > > > > > > import urllib2 > > > from binascii import hexlify, unhexlify > > > > > > host = "loc

Re: [argparse] mutually exclusive group with 2 sets of options

2013-08-06 Thread Francois Lafont
Le 07/08/2013 01:18, Francois Lafont a écrit : > For the inheritance of common options, I'll used something like > that (even if I prefer the oriented object side of the argparse > module): But I admit that this is a very simple and intelligent module. ;-) -- François Lafont -- http://mail.pyt

Re: Beginner question

2013-08-06 Thread Chris Down
On 2013-08-06 14:35, eschneide...@comcast.net wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. "if" statements do not fall through, because the first statement was matched, no other ones in the same chain will be evaluted. "elif

Re: Enum vs OrderedEnum

2013-08-06 Thread Ian Kelly
On Aug 6, 2013 5:15 PM, "Ethan Furman" wrote: > > Use the .value attribute instead. You could also substitute self for Environment. It feels more natural and readable to compare the enum instances rather than their value attributes. If I am ordering the values then that seems to imply that the e

Re: [ActivePython] Upgrading fails

2013-08-06 Thread Terry Reedy
On 8/6/2013 6:12 PM, Gilles wrote: Hello, I already posted in their forum, but got no reply and figured some people here might have experienced this too. I'm currently running ActivePython 2.5.1.1 on my XP Pro host. After downloading and running the installer to 2.7.2.5, I get the following er

Re: HTTP post with urllib2

2013-08-06 Thread Joel Goldstick
On Tue, Aug 6, 2013 at 7:35 PM, cerr wrote: > On Tuesday, August 6, 2013 4:08:34 PM UTC-7, Joel Goldstick wrote: >> On Tue, Aug 6, 2013 at 6:52 PM, cerr wrote: >> >> > Hi, >> >> > >> >> > Why does this code: >> >> > >> >> > #!/usr/bin/python >> >> > >> >> > >> >> > import urllib2 >> >> > from bin

Re: Enum vs OrderedEnum

2013-08-06 Thread Rhodri James
On Wed, 07 Aug 2013 00:46:39 +0100, Ian Kelly wrote: On Aug 6, 2013 5:15 PM, "Ethan Furman" wrote: Use the .value attribute instead. You could also substitute self for Environment. It feels more natural and readable to compare the enum instances rather than their value attributes. If I

Re: HTTP post with urllib2

2013-08-06 Thread MRAB
On 06/08/2013 23:52, cerr wrote: Hi, Why does this code: #!/usr/bin/python import urllib2 from binascii import hexlify, unhexlify host = "localhost" uri="/test.php" data ="\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64" #Hello World url="http://{0}{1}?f=test".format(host, uri) req = urllib2.Reques

Re: Newbie: static typing?

2013-08-06 Thread Chris Angelico
On Wed, Aug 7, 2013 at 12:02 AM, Terry Reedy wrote: > 3) The code falls into an infinite loop or recursion. > > The solution is to think before looping or recursing. This often involves > value checking (non-negative int or non-fractional float, for instance) > rather than type checking in the us

Re: HTTP post with urllib2

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 11:52 PM, cerr wrote: > ./post.py > Traceback (most recent call last): > File "./post.py", line 13, in > response = urllib2.urlopen(req, 120) > File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen > return _opener.open(url, data, timeout) > File "/usr/li

Re: Enum vs OrderedEnum

2013-08-06 Thread Ethan Furman
On 08/06/2013 04:46 PM, Ian Kelly wrote: On Aug 6, 2013 5:15 PM, "Ethan Furman" mailto:et...@stoneleaf.us>> wrote: Use the .value attribute instead. You could also substitute self for Environment. It feels more natural and readable to compare the enum instances rather than their value att

Re: Enum vs OrderedEnum

2013-08-06 Thread Ben Finney
Ian Kelly writes: > class Environment(OrderedEnum): I have nothing to add regarding the Python code, but I wanted to make a language correction: > gaia = 1 > fertile = 2 > terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10) > barren, tundra, dead, inferno, toxic,

Re: Class hierarchy problem

2013-08-06 Thread Ben Finney
Terry Reedy writes: > On 8/6/2013 11:36 AM, BrJohan wrote: > > > Consider a botanical classification system (somewhat analogous to my > > 'problem' as it effectively is related to classification of entities): > > > > A Domain should know about its Kingdoms, > > a Kingdom should know about its Phy

Re: Beginner question

2013-08-06 Thread eschneider92
Thanks that helped a lot! -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-06 Thread memilanuk
On 08/03/2013 10:57 AM, Aseem Bansal wrote: > I was writing a Python script for getting the user stats of a > website(Specifically codereview.stackexchange). I wanted to store the > stats in a database. I found Python3's sqlite3 library. I found that > I needed sql commands for using it. > > I hav

new to While statements

2013-08-06 Thread krismesenbrink
import random def room (): hp = 10 while hp != 0: random_Number = random.randint(1, 2) #asking if you want to roll/play des = input("Would you like to roll the die?") if des == ("y"): print ("Rolling the die...") print ("You rol

Re: new to While statements

2013-08-06 Thread snakeinmyboot
Hey there, cool idea you've got going on here! As far as I can tell though...what you want to happen, is indeed actually happening. Did you mean something else? Everytime I run the script and defeat a monster, it asks me if I want to roll the dice again. -- http://mail.python.org/mailman/listi

Re: new to While statements

2013-08-06 Thread krismesenbrink
and it seems you are right about that, i don't know what was wrong with my IDE before, i closed it and opened it up again,seemed to fix the problem. thanks for taking the time to look at it anyway! -- http://mail.python.org/mailman/listinfo/python-list

Re: new to While statements

2013-08-06 Thread snakeinmyboot
yea no problem. heres a little tip though so you atleast get something out of the post. monster_hp = monster_hp - damage_done can be simplified by writing monster_hp -= damage_done the -= means equal to whatever is on the left, minus whatevers on the right. this can be done with addition, mul

  1   2   >