RE: __init__ patterns

2018-08-30 Thread Dan Strohl via Python-list
I will put imports into my __init__ files, so that I can import things from the module directly instead of having to import from a file in the module. I almost never put code in the __init__'s, I have a couple of times put in something that was designed to modify which routine was imported

RE: syntax difference (type hints)

2018-06-18 Thread Dan Strohl via Python-list
> -Original Message- > From: Python-list On > Behalf Of Schachner, Joseph > Sent: Monday, June 18, 2018 7:58 AM > To: Ed Kellett ; python-list@python.org > Subject: RE: syntax difference (type hints) > > EXTERNAL MAIL: python-list-bounces+d.strohl=f5@python.org > > Assuming that

RE: Indented multi-line strings

2018-06-04 Thread Dan Strohl via Python-list
> > > No-one is saying a method is *worse* than a standalone function - they are > just saying it's *not sufficiently better* to justify creating a string > method that > replicates an existing stdlib function. > What about performance? I would expect a string method to perform better than a

RE: Indented multi-line strings

2018-06-01 Thread Dan Strohl via Python-list
> > It would probably have to go via python-ideas, but if it gets the OK there I > doubt it would need a PEP. > Cool, thanks! > There are a few key questions I'd expect to see come up. > > Why does this need to be a string method? Why can't it be a standalone > function? Maybe you should

RE: Indented multi-line strings

2018-06-01 Thread Dan Strohl via Python-list
> > I would prefer to remove the padding, like this: > > Test = """ > |Hello, this is a > | Multiline indented > |String > """.outdent(padding='|') > > Or write it like this? > > Test = """|Hello, this is a > | Multiline indented

RE: Override built in types... possible? or proposal.

2018-05-31 Thread Dan Strohl via Python-list
> > > > I am envisioning something in the header like an import statement > > where I could do; > > > > override str=my_string > > override list=my_list > > > > This would only be scoped to the current module and would not be > imported when that module was imported. > > > > Thoughts? > > > > Dan

Override built in types... possible? or proposal.

2018-05-31 Thread Dan Strohl via Python-list
Is it possible to override the assignment of built in types to the shorthand representations? And if not, is it a reasonable thought to consider adding? For example, right now, if I do: test = "this is a string", I get back str("this is a string"). What if I want to return this as

RE: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Dan Strohl via Python-list
> This is of course not a problem if the *trailing* quote determines the > indentation: > > a_multi_line_string = i''' >Py- > thon > ''' I get the point, but it feels like it would be a pain to use, and it "Feels" different from the other python indenting,

RE: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Dan Strohl via Python-list
> > How about we instead just use the rules from PEP 257 so that there aren't two > different sets of multi-line string indentation rules to have to remember? > > https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation > I like that, better to be closer to the existing

RE: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Dan Strohl via Python-list
> > > Personally though, I would not hard code it to knock out 4 leading > > spaces. I would have it handle spaces the same was that the existing > > parser does, if there are 4 spaces indending the next line, then it > > removes 4 spaces, if there are 6 spaces, it removes 6 spaces, etc... > >

RE: "Data blocks" syntax specification draft

2018-05-23 Thread Dan Strohl via Python-list
First of all, I suggest splitting this into a separate proposal (new thread) that way you will avoid confusion for people who are still considering the older proposal, and for the (probably many) people who have stopped reding the old thread due to some of the more heated conversations in

RE: "Data blocks" syntax specification draft

2018-05-22 Thread Dan Strohl via Python-list
> -Original Message- > > I think it would be appropriate to propose an alternative to TQS for this > specific purposes. Namely for making it easier to implement parsers and > embedded syntaxes. > > So what do I have now with triple quoted strings - a simple example: > > if 1: > s =

RE: "Data blocks" syntax specification draft

2018-05-21 Thread Dan Strohl via Python-list
On 5/19/18 10:58 PM, Mikhail V wrote: >> I have made up a printable PDF with the current version of the syntax >> suggestion. >> >> https://github.com/Mikhail22/Documents/blob/master/data-blocks-v01.pdf >> >> After some of your comments I've made some further re-considerations, >> e.g. element

RE: why does list's .remove() does not return an object?

2018-05-17 Thread Dan Strohl via Python-list
On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote: > I don't understand what this would return? x? You already have x. Is > it meant to make a copy? x has been mutated, so I don't understand the > benefit of making a copy of the 1-less x. Can you elaborate on the > problem you are trying

RE: Request for comments: use-cases for delayed evaluation

2018-05-17 Thread Dan Strohl via Python-list
I could easily see using all of the examples; I run into this pretty regularly. What about something like the following (which, honestly is really a combination of other examples). If I have a function that has multiple parameters, each of which might be expensive, but it might break out

RE: Best way to assert unit test cases with many conditions

2017-07-18 Thread Dan Strohl via Python-list
Ganesh; I'm not 100% sure what you are trying to do.. so let me throw out a few things I do and see if that helps... If you are trying to run a bunch of similar tests on something, changing only (or mostly) in the parameters passed, you can use self.subTest(). Like this: Def test_this(self):

RE: Users of namedtuple: do you use the _source attribute?

2017-07-17 Thread Dan Strohl via Python-list
I have never used it personally. It always looked interesting, but I never ran into a need to generate the source for it. -Original Message- From: Python-list [mailto:python-list-bounces+d.strohl=f5@python.org] On Behalf Of Steve D'Aprano Sent: Monday, July 17, 2017 9:58 AM To:

RE: Re: Clickable hyperlinks

2017-01-05 Thread Dan Strohl via Python-list
Keeping mind how this all works... Python is providing the data, the console/terminal/app handles how that data is displayed. There is no specification for text output to be hyperlinked (that I know about at least), so while some apps may handle specific coding to tell them that "this text

RE: Clickable hyperlinks

2017-01-05 Thread Dan Strohl via Python-list
The best bet (unless you know that you are outputting to a specific place, like html or excel) is to always include the "https://; or "http://; since most of the consoles / terminals that support clickable links are parsing them based on "seeing" the initial "http://;. If your output just

RE: Re: Clickable hyperlinks

2017-01-03 Thread Dan Strohl via Python-list
Keeping mind how this all works... Python is providing the data, the console/terminal/app handles how that data is displayed. There is no specification for text output to be hyperlinked (that I know about at least), so while some apps may handle specific coding to tell them that "this text

RE: Clickable hyperlinks

2017-01-03 Thread Dan Strohl via Python-list
The best bet (unless you know that you are outputting to a specific place, like html or excel) is to always include the "https://; or "http://; since most of the consoles / terminals that support clickable links are parsing them based on "seeing" the initial "http://;. If your output just

RE: reduction

2016-05-31 Thread Dan Strohl via Python-list
> My problem. I have lists of substrings associated to values: > > ['a','b','c','g'] => 1 > ['a','b','c','h'] => 1 > ['a','b','c','i'] => 1 > ['a','b','c','j'] => 1 > ['a','b','c','k'] => 1 > ['a','b','c','l'] => 0 # <- Black sheep!!! > ['a','b','c','m'] => 1 > ['a','b','c','n'] => 1 >

RE: Wanted Python programmer to join team

2016-05-16 Thread Dan Strohl via Python-list
> My team is getting more projects that it can handle so we are looking for > Python programers to join. You will be given tasks to complete full or part of > the project. > > Skype: piefektas > > Contact me now with short description about yourself, your skills and > projects you have worked

RE: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread Dan Strohl via Python-list
> > One other point for you, if your "__repr__(self)" code is the same as > > the "__str__(self)" code (which it looks like it is, at a glance at > > least), you can instead reference the __str__ method and save having a > > duplicate code block... > > Alternatively, consider: the ‘__repr__’

RE: Need help understanding list structure

2016-05-03 Thread Dan Strohl via Python-list
> I added a __repr__ method at the end of the gedcom library like so: > > def __repr__(self): > """ Format this element as its original string """ > result = repr(self.level()) > if self.pointer() != "": > result += ' ' + self.pointer() > result += ' '

RE: Need help understanding list structure

2016-05-03 Thread Dan Strohl via Python-list
Take a look at the docs for print() https://docs.python.org/3.5/library/functions.html#print str() https://docs.python.org/3.5/library/stdtypes.html#str repr() https://docs.python.org/3.5/library/functions.html#repr When you do "print(object)", python will run everything through str() and

RE: What should Python apps do when asked to show help?

2016-04-28 Thread Dan Strohl via Python-list
Yup.. another reason to use something like argparse... you define the argument descriptions, help, and when you raise an error, it automatically handles the output, sending it to the right place (stderr/stdout)... as well as allowing you to define different levels of verbosity easily... (or not

RE: What should Python apps do when asked to show help?

2016-04-28 Thread Dan Strohl via Python-list
I would hesitate to take this approach unless the tool was one that only I was going to be using, and I knew exactly what environments it was going to be in. I know that many of the system items in python work differently in different operating systems, and different os's report things

RE: What should Python apps do when asked to show help?

2016-04-28 Thread Dan Strohl via Python-list
From: John Wong [mailto:gokoproj...@gmail.com] Sent: Thursday, April 28, 2016 10:06 AM To: Dan Strohl <d.str...@f5.com> Cc: alister <alister.w...@ntlworld.com>; python-list@python.org Subject: Re: What should Python apps do when asked to show help? On Thu, Apr 28, 2016 at 1:02 PM, Da

RE: What should Python apps do when asked to show help?

2016-04-28 Thread Dan Strohl via Python-list
I would suggest using argparse https://docs.python.org/3/library/argparse.html as it handles all of that natively... including validating arguments, showing errors, help, etc... however, assuming you don't want to; Send it to stdout, that allows the user to redirect it if they want to (and

RE: Controlling the passing of data

2016-04-28 Thread Dan Strohl via Python-list
If I am reading this correctly... you have something like (you will have to excuse my lack of knowledge about what kinds of information these actually are): 1234 first 5678 second And you want something like: nominations = [(1,1234), (2,5678)] meetings =

RE: online python courses

2016-04-28 Thread Dan Strohl via Python-list
I've heard good things about codeacademy.com and learnpython.org. Also, I've heard that pycharm educational edition is helpful. (https://www.jetbrains.com/pycharm-edu/ ) I haven't personally tried any of these though, so your mileage may vary. Good Luck! Dan Strohl > -Original

RE: Controlling the passing of data

2016-04-28 Thread Dan Strohl via Python-list
In addition to Peter's points, - I would suggest breaking out the list comprehensions into standard for loops and/or functions. That makes it easier to read and troubleshoot. (you can always re-optimize It if needed.) - Peter's point about making things into functions will also help

RE: How to print a part of a string?

2016-04-15 Thread Dan Strohl via Python-list
As with lots of things in python, there are lots of ways of approaching this, here are some hints for you to think about (in no particular order): - REGEX - replace() - string[:y] - split() And of course, you could consider creating a table with every possible string that could start with

RE: how to setup for localhost:8000

2016-04-14 Thread Dan Strohl via Python-list
If you got an empty page with no errors (and no warnings trying to get there...) it is likely that your server is working, and you are trying to access it correctly, but the server is not serving anything. Most of the time, if the server is not present, you will get a timeout error saying the

RE: Replace weird error message?

2016-03-19 Thread Dan Strohl via Python-list
Actually, I think that was the complete code... give it a try... "{:02}".format("1") produces the error listed. I agree the error is not very clear, since the "=" was not passed, it seems like an incorrect error. What about something like: "ValueError: '=' and '0' padding are not allowed in

RE: Encapsulation in Python

2016-03-10 Thread Dan Strohl via Python-list
> I've been studying Object Oriented Theory using Java. Theoretically, all > attributes should be private, meaning no one except the methods itself can > access the attribute; > > public class Foo { > private int bar; > ... Why? I mean sure, lots of them should be, but if I am doing