> Suppose I'm creating a class that represents a bearing or azimuth,
> created either from a string of traditional bearing notation
> ("N24d30mE") or from a number indicating the angle in degrees as
> usually measured in trigonometry (65.5, measured counter-clockwise
> from the x-axis). The class
> Hello All,
>
> I just made something pretty simple that I intend to use while creating
> database tables. It is still in the basic form, and much needs to be added.
> However, I use introspection to make it a bit easier and less work on the
> user.
>
> I would want my code to be reviewed by this
I am logging to my Apache web server, using this Apache format:
LogFormat "%{%Y-%m-%d %H:%M:%S}t %U %q" scriptlog
CustomLog /var/log/apache2/script.log scriptlog
My code is as follows:
#!/usr/bin/env python3
import logging, logging.handlers, sys
logger = logging.getLogger('simple_example')
logge
> I I would like to have numbers expressed in scientific notation in
> legend annotations. Does anybody know how to do that?
>
Not sure why legend annotations makes the problem different, but
perhaps this is a start:
$ python3
Python 3.2 (r32:88445, Jun 11 2011, 10:38:04)
[GCC 4.4.3] on linux2
Ty
> here is my code :
> import urllib
> import lxml.html
> down='http://download.v.163.com/dl/open/00DL0QDR0QDS0QHH.html'
> file=urllib.urlopen(down).
> read()
> root=lxml.html.document_fromstring(file)
> tnodes = root.xpath("//a/@href[contains(string(),'mp4')]")
> for i,add in enumerate(tnodes):
>
> thank you, I am trying to learn python, but I am having a hard to find
> a good introduction to it.
Try this:
http://docs.python.org/py3k/tutorial/
--
http://mail.python.org/mailman/listinfo/python-list
> One of the difficulties on this list is that we don't have
> two-dimensional people. Even our worst trolls have some redeeming
> features. I can't just dismiss Ferrous out of hand...
Indeed, and that is a "problem" with humanity in general.
It is proof that God (or the universe) has a sense of h
I want to tell whether an object is a regular expression pattern.
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> s = "hello"
>>> type(s)
>>> isinstance(s, str)
True
>>> my_pattern = re.co
import os
os.system("i=3")
> 0
os.system("echo $i")
>
> 0
>
> why i can not get the value of i?
Each call to os.system starts a new shell. Think about what would
happen if you opened a terminal and typed:
$ i=3
Then, close that terminal and open a new one. You would not be surpr
Python 3.2.2 (default, Feb 14 2012, 08:06:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tempfile import NamedTemporaryFile
>>> f = NamedTemporaryFile(delete=False)
>>> f
>>> f.name
'/tmp/tmpqxnd_4'
>>> f.write(
> NamedTemporaryFile by default opens a file in binary mode ('w+b'). Write
> bytes or specify text mode.
>
f.write(b"Hello World!\n")
> 13
ft = NamedTemporaryFile('w+', delete=False)
ft.write("Hello World!\n")
> 13
Thank you Chris and Serhiy, that helped. I'm inclined to open a
doc
> Yep, that looks like a docs bug (it was probably copied straight in
> from the 2.x docs). Nice and easy to fix, you could submit a patch
> with the bug report and make the devs love you!
Done: http://bugs.python.org/issue17271.
--
http://mail.python.org/mailman/listinfo/python-list
> Python has a nice Tutorial for beginners. It is an integral part of the doc
> set. To ignore that (and the indexes) in discussing the usability of Python
> docs by beginners is to lie. (If beginners who actually read the tutorial
> have problems with particular paragraphs, improvements can be and
> Thanks for your replies. Just to be clear this is for a interview and they
> would like me to figure out what the code does and come back with some test
> cases. I don't need to code the tests, just give some high level tests. As
> far as I can make out it is some system where you input your name
> Am I the only one here who has used a typewriter?
>
> I used one. And http://en.wikipedia.org/wiki/White-Out. And
http://en.wikipedia.org/wiki/Correction_tape.
My wife typed her dissertation on this:
http://en.wikipedia.org/wiki/File:Hardwarewordprocessor.png.
--
http://mail.python.org/mailma
> NwInvDb = NetworkInventoryDatabase, yes you are correct, it creates the
database handle and makes it ready for use.
I am interested in opinions. I for one dislike abbreviations on the theory
that programs are read more than they are written. I would probably use
this variable name:
network_in
I have a file such as:
$ cat my_data
Starting a new group
a
b
c
Starting a new group
1
2
3
4
Starting a new group
X
Y
Z
Starting a new group
I am wanting a list of lists:
['a', 'b', 'c']
['1', '2', '3', '4']
['X', 'Y', 'Z']
[]
I wrote this:
#!/usr/bin/python3
#!/usr/bin/python3
> from itertools import groupby
>
> def get_lines_from_file(file_name):
> with open(file_name) as reader:
> for line in reader.readlines():
> yield(line.strip())
>
> counter = 0
> def key_func(x):
> if x.startswith("Starting a new group"):
> g
I will be receiving email that contains, say, 10 images, and I want to
forward that message on after removing, say, 5 of those images. I will
remove based on size, for example 1679 bytes. I am aware that other images
besides the unwanted ones could be 1679 bytes but this is unlikely and the
impac
This seemed to work.
#!/usr/bin/env python3
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.iterators import typed_subpart_iterator
from email.generator import Generator, BytesGenerator
import email.iterators
imp
Hi, what is the difference between:
def MyClass(object):
pass
and
def MyClass():
pass
--
http://mail.python.org/mailman/listinfo/python-list
I saw this posted in the July issue but did not see any follow-up there:
$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 500
>>> b = 500
>>> a == b
True
>>> a is b
False
>>> p = 50
>>> q
$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "x.vsd-dir".rstrip("-dir")
'x.vs'
I expected 'x.vsd' as a return value.
--
http://mail.python.org/mailman/listinfo/python-list
2010/7/20 Νίκος :
> Hello guys! This is my first post in this group!
I do not have an answer to your question, other than to suggest you
look at (and/or post) relevant lines from Apache's access.log and
error.log.
I write mostly to say that, in my experience, folks on this list are
very helpful,
Hello,
The Popen call does not return if the underlying OS call runs longish,
as the example below shows.
Although, if the underlying OS call is merely "sleep N" it will return
even after quite a long time.
wikiu...@dvprwiki1:~> python --version
Python 2.6.4
wikiu...@dvprwiki1:~> time /opt/confl
>
> I made a tool called PythonBuddy (http://pythonbuddy.com/).
>
> I made this so that MOOCs like edX or codecademy could easily embed and
> use this on their courses so students wouldn't have to go through the
> frustrations of setting up a Python environment and jump right into Python
> programm
>
> I have this code which I got from https://www.tutorialspoint.
> com/python/python_command_line_arguments.htm The example works fine but
> when I modify it to what I need, it only half works. The problem is the
> try/except. If you don't specify an input/output, they are blank at the end
> but i
>
> However, it's simply a technical fact: the thing which we moderate is the
>> mailing list. We can control which posts make it through from the newsgroup
>> by blocking them at the gateway. But the posts will continue to appear on
>> comp.lang.python which is, as the description says, unmoderate
>
> The example command is: Lockable("diary", "under Sam's bed", tiny_key,
> True)
>
> And I keep getting a NameError: tiny_key is not defined.
>
> What do I do?
>
Without knowing what your professor intends this is a guess: define
tiny_key. For example
tiny_key = "some string"
thing = Lockable
>
> P=input("X/O:")
> if P=="X":
> my_func1()
> else:
> my_func2()
>
>
>
> why cant function to print X or O win...
>
As a beginner I'd try to code using Python idioms rather than writing
Python using BASIC idioms.
Try to understand how this code works:
https://codereview.stackexchange.com
< start code >
import itertools
data = """Line1
Line2
Line4
Line5"""
def test_to_start(s):
return "2" in s
for line in itertools.dropwhile(test_to_start, data.splitlines()):
print(line)
< end code >
I expect:
$ python3 dropwhile.py
Line2
Line4
Line5
I get:
$ pyth
>
> menu_list = ["O -open account"]
> menu_list =["l - load details"]
> menu_list =["D- display details"]
> menu_list =["A - Make deposit"]
> menu_list =["W- Make withdraw",]
> menu_list =["S - save"]
> menu_list =["Q - quit"]
>
> command = input("command:")
> if command.upper() == "O":
> open_()
>
>
>
>> The first section does not do what I think you want: a list with 7
> options. It makes a list with one option, then overwrites it with a new
> list with one option, and so on. You want something like:
> menu_list = [
> "O - open account"
> "L - load details"
> "D - display det
>
> I have a problem to finding file in Python path,Anybody knows how to solve
> it?
>
> Unexpected error:
> Traceback (most recent call last):
> File
> "/home/nurzat/Documents/vmtk-build/Install/bin/vmtklevelsetsegmentation",
> line 20, in
> from vmtk import pypeserver
> File "/usr/loca
>
> I need the triangle to be in reverse. The assignment requires a nested
> loop to generate a triangle with the user input of how many lines.
>
> Currently, I get answers such as: (A)
>
> OOO
> OO
> O
>
> When I actually need it to be like this: (B)
>
> OOO
>OO
> O
>
Try the
This gives the expected results:
with open(data_file, newline="") as reader:
csvreader = csv.DictReader(reader)
for row in csvreader:
#print(row)
match row[RULE_TYPE]:
case "RANGE":
print("range")
case "MANDATORY":
print("mandatory")
case _:
print("nothing to do")
This:
RANGE = "RANGE"
MANDATORY
3 at 6:01 PM Greg Ewing via Python-list <
python-list@python.org> wrote:
> On 8/06/23 10:18 am, Jason Friedman wrote:
> > SyntaxError: name capture 'RANGE' makes remaining patterns unreachable
>
> The bytecode compiler doesn't know that you intend RANGE
> to be
I'm writing a database connectivity module to be used by other modules and
leveraging the jaydebeapi module.
>From what I can tell jaydebeapi contains no built-in timeout capability, so
then I turned to https://pypi.org/project/timeout-decorator/.
My goal is to have a default timeout of, say, 10 se
import inspect
def my_example(arg1, arg2):
print(inspect.stack()[0][3])
my_frame = inspect.currentframe()
args,_,_,values = inspect.getargvalues(my_frame)
args_rendered = [f"{x}: {values[x]}" for x in args]
print(args_rendered)
my_example("a", 1)
The above "works" in the sense it prints what I
> My question is: let's say I wanted to add a type hint for my_frame.
> >
> > my_frame: some_class_name = inspect.currentframe()
> >
> > What would I put for some_class_name?
> > "frame" (without quotations) is not recognized,
> > Nor is inspect.frame.
>
> We know Python code is executed in an exec
>
> Jason Friedman wrote at 2023-8-3 21:34 -0600:
> > ...
> >my_frame = inspect.currentframe()
> > ...
> >My question is: let's say I wanted to add a type hint for my_frame.
>
> `my_frame` will be an instance of `Types.FrameType`.
>
Confirmed. Th
I want to be able to write code like this:
with Database() as mydb:
conn = mydb.get_connection()
cursor = conn.get_cursor()
cursor.execute("update table1 set x = 1 where y = 2")
cursor.close()
cursor = conn.get_cursor()
cursor.execute("update table2 set a = 1 where b = 2")
cursor.close()
I'd like
I have two questions, please (this is after reading
https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#automatically-label-sections
).
This is my project structure:
my_project
api
stuff1.py
stuff2.py
lib
stuff3.py
stuff4.py
main_application.py
>
> def construct_response(exit_code: int, message: str) -> Response:
> """
> Construct a Flask-suitable response
>
> :param exit_code: 0 or something else
> :param message: something useful
> :return: a Flask-suitable response
> """
>
>
> @app.route(f"/{version}/", methods=
And I can answer my own Question 2:
:func:`my_project.main_application.construct_response`
On Mon, Aug 28, 2023 at 1:39 PM Jason Friedman wrote:
> def construct_response(exit_code: int, message: str) -> Response:
>> """
>> Construct a Flask-suitable re
def construct_response(exit_code: int, message: str) -> Response:
>> """
>> Construct a Flask-suitable response
>>
>> :param exit_code: 0 or something else
>> :param message: something useful
>> :return: a Flask-suitable response
>> """
>>
>>
>> @app.route(f"/{version}/", me
On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list <
python-list@python.org> wrote:
> which python version is better to be used and how to make sure it works on
> my window 10 because i downloaded it and it never worked so I uninstall to
> do that again please can you give me the steps
On Wed, Aug 21, 2024 at 4:04 PM Daniel via Python-list <
python-list@python.org> wrote:
>
> An example of use, here's a weather service tied to a finger. Put your
> city name as the user. This isn't mine, but it is inspiring. Example:
>
> finger mi...@graph.no
>
> For all options, go to the help f
>
> (a) An error-prone "feature" is returning -1 if a substring is not found
> by "find", since -1 currently refers to the last item. An example:
>
> >>> s = 'qwertyuiop'
> >>> s[s.find('r')]
> 'r'
> >>> s[s.find('p')]
> 'p'
> >>> s[s.find('a')]
> 'p'
> >>>
>
> If "find" is unsuccessful, an er
🙏
On Tue, Dec 3, 2024 at 5:06 PM Thomas Wouters via Python-list <
python-list@python.org> wrote:
> Another big release day! Python 3.13.1 and 3.12.8 were regularly scheduled
> releases, but they do contain a few security fixes. That makes it a nice
> time to release the security-fix-only versions
>
> Trying to compile Python-3.12.9 on Ubuntu-24.04
>
> The compilation is complete without errors but I have this message:
>
>
> The necessary bits to build these optional modules were not foun
201 - 251 of 251 matches
Mail list logo