Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Jason Friedman
> 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

Re: Python lib for creating Database tables

2012-01-11 Thread Jason Friedman
> 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

logging and httphandler

2012-01-13 Thread Jason Friedman
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

Re: scientific notation in legend (pylab)

2012-01-14 Thread Jason Friedman
> 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

Re: why i can get nothing?

2012-01-15 Thread Jason Friedman
> 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): >  

Re: scientific notation in legend (pylab)

2012-01-18 Thread Jason Friedman
> 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

Re: Formatting a column's value output

2013-02-03 Thread Jason Friedman
> 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

Comparing types

2013-02-16 Thread Jason Friedman
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

Re: call from pthon to shell

2013-02-16 Thread Jason Friedman
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

NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
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(

Re: NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
> 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

Re: NamedTemporaryFile does not match documentation

2013-02-21 Thread Jason Friedman
> 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

Re: Do you feel bad because of the Python docs?

2013-02-27 Thread Jason Friedman
> 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

Re: Help with python code!

2013-04-02 Thread Jason Friedman
> 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

Re: I hate you all

2013-04-06 Thread Jason Friedman
> 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

Re: classes and sub classes?

2013-04-14 Thread Jason Friedman
> 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

itertools.groupby

2013-04-20 Thread Jason Friedman
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

Re: itertools.groupby

2013-04-21 Thread Jason Friedman
#!/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

Remove some images from a mail message

2013-04-21 Thread Jason Friedman
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

Re: Remove some images from a mail message

2013-04-23 Thread Jason Friedman
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

subclass of object

2010-04-02 Thread Jason Friedman
Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass -- http://mail.python.org/mailman/listinfo/python-list

pythonrag

2010-04-05 Thread Jason Friedman
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

rstrip()

2010-07-16 Thread Jason Friedman
$ 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

Re: Trying to redirect every urel request to test.py script with the visitors page request as url parameter.

2010-07-20 Thread Jason Friedman
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,

Subprocess does not return for longer-running process

2010-09-21 Thread Jason Friedman
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

Re: Online Python Editor with Live Syntax Checking

2017-03-05 Thread Jason Friedman
> > 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

Re: Python Command Line Arguments

2017-04-12 Thread Jason Friedman
> > 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

Re: Moderating the list [was: Python and the need for speed]

2017-04-12 Thread Jason Friedman
> > 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

Re: homework confusion

2017-04-12 Thread Jason Friedman
> > 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

Re: TIC TAE TOE's problem(i am beginner)

2017-04-15 Thread Jason Friedman
> > 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

Not understanding itertools.dropwhile()

2017-04-29 Thread Jason Friedman
< 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

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2017-05-12 Thread Jason Friedman
> > 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_() >

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2017-05-12 Thread Jason Friedman
> > >> 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

Re: No module named vtkCommonCorePython

2017-05-20 Thread Jason Friedman
> > 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

Re: Nested Loop Triangle

2017-05-25 Thread Jason Friedman
> > 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

Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
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

Re: Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
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

Trouble with defaults and timeout decorator

2023-06-24 Thread Jason Friedman via Python-list
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

How to find the full class name for a frame

2023-08-03 Thread Jason Friedman via Python-list
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

Re: How to find the full class name for a frame

2023-08-04 Thread Jason Friedman via Python-list
> 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

Re: How to find the full class name for a frame

2023-08-04 Thread Jason Friedman via Python-list
> > 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

Context manager for database connection

2023-08-23 Thread Jason Friedman via Python-list
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

Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
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

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
> > 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=

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
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

Re: Generating documentation with Sphinx

2023-08-28 Thread Jason Friedman via Python-list
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

Re: Help

2023-11-06 Thread Jason Friedman via Python-list
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

Re: new here

2024-08-21 Thread Jason Friedman via Python-list
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

Re: Two python issues

2024-11-05 Thread Jason Friedman via Python-list
> > (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

Re: [RELEASE] Python 3.13.1, 3.12.8, 3.11.11, 3.10.16 and 3.9.21 are now available

2024-12-03 Thread Jason Friedman via Python-list
🙏 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

Re: Version of OpenSSl ?

2025-02-09 Thread Jason Friedman via Python-list
> > 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

<    1   2   3