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 (i.e.
> -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 we
> >
> 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
>
> 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 publi
>
> 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
>
> >
> > 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 S
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
my_string
> 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, which
>
> 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 stand
>
> > 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...
> >
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 there.
> -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 =
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 se
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
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 ear
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):
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: pyth
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 sho
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 lo
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 s
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 lo
> 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
> ['a','b','
> 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 on.
> > 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__’ metho
> 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 += ' '
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
outp
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
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 different
From: John Wong [mailto:gokoproj...@gmail.com]
Sent: Thursday, April 28, 2016 10:06 AM
To: Dan Strohl
Cc: alister ; 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, Dan Strohl via Python-list
mailto:python-list@python.org
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
play
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 = [(1,'first')
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 Message
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
troublesh
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 "ABC
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 b
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 s
> 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 some
37 matches
Mail list logo